Package'reqres'October2,2019TypePackageTitlePowerfulClassesforHTTPRequestsandResponsesVersion0.
2.
3MaintainerThomasLinPedersenDescriptionInordertofacilitateparsingofhttprequestsandcreatingappropriateresponsesthispackageprovidestwoclassestohandlealotofthehousekeepinginvolvedinworkingwithhttpexchanges.
Theinfrastructurebuildsuponthe'rook'specicationandisthuswellsuitedtobecombinedwith'httpuv'basedwebservers.
LicenseMIT+leLICENSEEncodingUTF-8LazyDataTRUEDependsR(>=2.
10)ImportsR6,assertthat,stringi,urltools,tools,brotli,jsonlite,xml2,webutils,utilsRoxygenNote6.
1.
1Suggestsery,testthat,covrURLhttps://reqres.
data-imaginist.
com,https://github.
com/thomasp85/reqres#reqresBugReportshttps://github.
com/thomasp85/reqres/issuesNeedsCompilationnoAuthorThomasLinPedersen[cre,aut]()RepositoryCRANDate/Publication2019-10-0220:00:03UTC12default_formattersRtopicsdocumented:default_formatters2default_parsers3formatters3parsers5Request7Response11to_http_date14Index16default_formattersAlistofdefaultformattermappingsDescriptionThislistmatchesthemostnormalmimetypeswiththeirrespectiveformattersusingdefaultargu-ments.
Forano-frillsrequestparsingthiscanbesupplieddirectlytoResponse$format().
Toaddormodifytothislistsimplysupplytheadditionalparsersassecond,third,etc,argumentandtheywilloverwriteoradddependingonwhetheritspeciesamimetypealreadypresent.
Usagedefault_formattersSeeAlsoformattersforanoverviewofthebuildinformattersinreqresExamples##Notrun:res$format(default_formatters,text/plain=format_plain(sep=))##End(Notrun)default_parsers3default_parsersAlistofdefaultparsermappingsDescriptionThislistmatchesthemostnormalmimetypeswiththeirrespectiveparsersusingdefaultarguments.
Forano-frillsrequestparsingthiscanbesupplieddirectlytoRequest$parse().
Toaddormod-ifytothislistsimplysupplytheadditionalparsersassecond,third,etc,argumentandtheywilloverwriteoradddependingonwhetheritspeciesamimetypealreadypresent.
Usagedefault_parsersSeeAlsoparsersforanoverviewofthebuildinparsersinreqresExamples##Notrun:req$parse(default_parsers,application/json=parse_json(flatten=TRUE))##End(Notrun)formattersPre-suppliedformattinggeneratorsDescriptionThissetoffunctionscanbeusedtoconstructformattingfunctionsadheringtotheResponse$format()requirements.
Usageformat_json(dataframe="rows",matrix="rowmajor",Date="ISO8601",POSIXt="string",factor="string",complex="string",raw="base64",null="list",na="null",auto_unbox=FALSE,digits=4,pretty=FALSE,force=FALSE)format_plain(sep="\n")format_xml(encoding="UTF-8",options="as_xml")format_html(encoding="UTF-8",options="as_html")format_table(.
.
.
)4formattersArgumentsdataframehowtoencodedata.
frameobjects:mustbeoneof'rows','columns'or'values'matrixhowtoencodematricesandhigherdimensionalarrays:mustbeoneof'rowma-jor'or'columnmajor'.
DatehowtoencodeDateobjects:mustbeoneof'ISO8601'or'epoch'POSIXthowtoencodePOSIXt(datetime)objects:mustbeoneof'string','ISO8601','epoch'or'mongo'factorhowtoencodefactorobjects:mustbeoneof'string'or'integer'complexhowtoencodecomplexnumbers:mustbeoneof'string'or'list'rawhowtoencoderawobjects:mustbeoneof'base64','hex'or'mongo'nullhowtoencodeNULLvalueswithinalist:mustbeoneof'null'or'list'nahowtoprintNAvalues:mustbeoneof'null'or'string'.
Defaultsareclassspecicauto_unboxautomaticallyunboxallatomicvectorsoflength1.
Itisusuallysafertoavoidthisandinsteadusetheunboxfunctiontounboxindividualelements.
Anex-ceptionisthatobjectsofclassAsIs(i.
e.
wrappedinI())arenotautomaticallyunboxed.
Thisisawaytomarksinglevaluesaslength-1arrays.
digitsmaxnumberofdecimaldigitstoprintfornumericvalues.
UseI()tospecifysignicantdigits.
UseNAformaxprecision.
prettyaddsindentationwhitespacetoJSONoutput.
CanbeTRUE/FALSEoranumberspecifyingthenumberofspacestoindent.
Seeprettifyforceunclass/skipobjectsofclasseswithnodenedJSONmappingsepThelineseparator.
Plaintextwillbesplitintomultiplestringsbasedonthis.
encodingThecharacterencodingtouseinthedocument.
Thedefaultencodingis'UTF-8'.
Availableencodingsarespeciedathttp://xmlsoft.
org/html/libxml-encoding.
html#xmlCharEncoding.
optionsdefault:'format'.
ZeroormoreofformatFormatoutputno_declarationDroptheXMLdeclarationno_empty_tagsRemoveemptytagsno_xhtmlDisableXHTML1rulesrequire_xhtmlForceXHTML1rulesas_xmlForceXMLoutputas_htmlForceHTMLoutputformat_whitespaceFormatwithnon-signicantwhitespace.
.
.
parameterspassedontowrite.
table()ValueAfunctionacceptinganRobjectparsers5SeeAlsoparsersforconvertingRequestbodiesintoRobjectsdefault_formattersforalistthatmapsthemostcommonmimetypestotheirrespectiveformattersExamplesfake_rook.
Usethetypeargumenttooverwritetheautomatictypeinferencefromtheleextension.
status_with_text(code)Setsthestatustocodeandsetsthebodytotheassociatedstatuscodedescription(e.
g.
BadGatewayfor502L)set_cookie(name,value,encode=TRUE,expires=NULL,http_only=NULL,max_age=NULL,path=NULL,secureAddsthecookiegivenbynametothegivenvalue,optionallyurlencodingit,alongwithanyadditionaldirectives.
Seehttps://developer.
mozilla.
org/en-US/docs/Web/HTTP/Headers/Set-Cookieforadescriptionofthedifferentdirectives.
Ifthecookiealreadyexistsitwillbeoverwritten.
Thevalidityofthedirectiveswillautomaticallybechecked.
expiresexpectsaPOSIXctobject,http_onlyandsecureexpectalogical,max_ageexpectsaninte-ger,pathastring,andsame_siteeither"Lax"or"Strict"remove_cookie(name)Removesthecookienamednamefromtheresponse.
has_cookie(name)Querieswhethertheresponsecontainsacookienamednameset_links(.
.
.
)SetstheLinkheaderbasedonthenamedargumentspassedto.
.
.
.
Thenameswillbeusedforthereldirective.
format(.
.
.
,autofail=TRUE,compress=TRUE)Basedontheformatterspassedinthrough.
.
.
contentnegotiationisperformedwithrequestandthepreferredformatterischosen.
TheContent-Typeheaderissetautomatically.
Ifcompress=TRUEthecompress()methodwillbecalledafterformatting.
Ifanerrorisencounteredandautofail=TRUEtheresponsewillbesetto500.
Ifaformatterisnotfoundandautofail=TRUEtheresponsewillbesetto406.
IfformattingissuccessfulitwillreturnTRUE,ifnotitwillreturnFALSEcompress(priority=c('gzip','deflate','br','identity'))Basedontheprovidedpri-ority,anencodingisnegotiatedwiththerequestandapplied.
TheContent-Encodingheaderissettothechosencompressionalgorithm.
content_length()Calculatesthelength(inbytes)ofthebody.
ThisisthenumberthatgoesintotheContent-Lengthheader.
NotethattheContent-Lengthheaderissetautomaticallybyhttpuvsothismethodshouldonlybecallediftheresponsesizeisneededforotherreasons.
as_list()ConvertstheobjecttoalistforfurtherprocessingbyaRookcompliantserversuchashttpuv.
WillsetContent-Typeheaderifmissingandconvertanon-rawbodytoasinglecharacterstring.
SeeAlsoRequestforhandlinghttprequestsExamplesfake_rook<-fiery::fake_request(http://example.
com/testid=34632&question=who+is+hadley,content=Thisiselaborateruse,headers=list(Accept=application/json;text/*,Content_Type=text/plain))14to_http_datereq<-Request$new(fake_rook)res<-Response$new(req)res#Setthebodytotheassociatedstatustextres$status_with_text(200L)res$body#InferContent-Typefromfileextensionres$type<-jsonres$type#Prepareafilefordownloadres$attach(system.
file(DESCRIPTION,package=reqres))res$typeres$bodyres$get_header(Content-Disposition)#Cleaningupconnectionsrm(fake_rook,req,res)gc()to_http_dateFormattimestampstomatchtheHTTPspecsDescriptionDates/timesinHTTPheadersneedsaspecicformattobevalid,andisfurthermorealwaysgiveninGMTtime.
Thesetwofunctionsaidsinconvertingbackandforthbetweentherequiredformat.
Usageto_http_date(time,format=NULL)from_http_date(time)ArgumentstimeAstringoranobjectcoercibletoPOSIXctformatIncasetimeisnotaPOSIXctobjectaspecicationhowthestringshouldbeinterpreted.
Valueto_http_date()returnsaproperlyformattedstring,whilefrom_http_date()returnsaPOSIXctobjectto_http_date15Examplestime<-to_http_date(Sys.
time())timefrom_http_date(time)IndexTopicdatasetsdefault_formatters,2default_parsers,3Request,7Response,11as.
list.
Response(Response),11as.
Request(Request),7default_formatters,2,5default_parsers,3,7flatten,6format_html(formatters),3format_json(formatters),3format_plain(formatters),3format_table(formatters),3format_xml(formatters),3formatters,2,3,7from_http_date(to_http_date),14is.
Request(Request),7is.
Response(Response),11parse_html(parsers),5parse_json(parsers),5parse_multiform(parsers),5parse_plain(parsers),5parse_queryform(parsers),5parse_table(parsers),5parse_xml(parsers),5parsers,3,5,5,10prettify,4rawToChar(),10read.
table(),7Request,7,13Response,10,11to_http_date,14unbox,4write.
table(),416
A400互联怎么样?A400互联是一家成立于2020年的商家,A400互联是云服务器网(yuntue.com)首次发布的云主机商家。本次A400互联给大家带来的是,全新上线的香港节点,cmi+cn2线路,全场香港产品7折优惠,优惠码0711,A400互联,只为给你提供更快,更稳,更实惠的套餐,香港节点上线cn2+cmi线路云服务器,37.8元/季/1H/1G/10M/300G,云上日子,你我共享。...
pigyun怎么样?PIGYun成立于2019年,2021是PIGYun为用户提供稳定服务的第三年,期待我们携手共进、互利共赢。PIGYun为您提供:香港CN2线路、韩国CN2线路、美西CUVIP-9929线路优质IaaS服务。月付另有通用循环优惠码:PIGYun,获取8折循环优惠(永久有效)。目前,PIGYun提供的香港cn2云服务器仅29元/月起;韩国cn2云服务器仅22元/月起;美国CUVI...
RAKsmart商家一直以来在独立服务器、站群服务器和G口和10G口大端口流量服务器上下功夫比较大,但是在VPS主机业务上仅仅是顺带,尤其是我们看到大部分主流商家都做云服务器,而RAKsmart商家终于开始做云服务器,这次试探性的新增美国硅谷机房一个方案。月付7.59美元起,支持自定义配置,KVM虚拟化,美国硅谷机房,VPC网络/经典网络,大陆优化/精品网线路,支持Linux或者Windows操作...
404notfound为你推荐
伪装微信地理位置微信和微信伪装地理位置打不开怎么办?一点就一闪就完了怎么在qq空间里添加背景音乐如何在qq空间中添加背景音乐吴晓波频道买粉罗辑思维,晓松奇谈,鸿观,吴晓波频道,财经郎眼哪个更有深度xv播放器下载求手机可以看xv格式的视频播放器保护气球气球保护液可以用什么来代替?宕机人们说的宕机是什么意思cr2格式如何打开CR2格式的照片呢小米手柄小米手柄怎么用?小米手柄手机用小米手柄能玩什么游戏宽带接入服务器用wifi连不上服务器怎么办
西安服务器租用 老左 cdn服务器 紫田 火车票抢票攻略 云鼎网络 网站挂马检测工具 中国智能物流骨干网 创梦 anylink 炎黄盛世 刀片服务器的优势 免费防火墙 常州联通宽带 免费mysql数据库 中国域名 免费网络 lamp的音标 网站加速 攻击服务器 更多