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
CloudCone 商家在以前的篇幅中也有多次介绍到,这个商家也蛮有意思的。以前一直只有洛杉矶MC机房,而且在功能上和Linode、DO、Vultr一样可以随时删除采用按时计费模式。但是,他们没有学到人家的精华部分,要这样的小时计费,一定要机房多才有优势,否则压根没有多大用途。这不最近CloudCone商家有点小变化,有新人洛杉矶优化线路,具体是什么优化的等会我测试看看线路。内存CPU硬盘流量价格...
DMIT怎么样?DMIT是一家美国主机商,主要提供KVM VPS、独立服务器等,主要提供香港CN2、洛杉矶CN2 GIA等KVM VPS,稳定性、网络都很不错。支持中文客服,可Paypal、支付宝付款。2020年推出的香港国际线路的KVM VPS,大带宽,适合中转落地使用。现在有永久9折优惠码:July-4-Lite-10OFF,季付及以上还有折扣,非 中国路由优化;AS4134,AS4837 均...
OneTechCloud(易科云)是一家主打CN2等高端线路的VPS主机商家,成立于2019年,提供的产品包括VPS主机和独立服务器租用等,数据中心可选美国洛杉矶、中国香港、日本等,有CN2 GIA线路、AS9929、高防、原生IP等。目前商家针对全场VPS主机提供月付9折,季付8折优惠码,优惠后香港VPS最低季付64元起(≈21.3元/月),美国洛杉矶CN2 GIA线路+20Gbps防御型VPS...
404notfound为你推荐
博客外链外链都要怎么做?博客外链有没有效果?缓冲区溢出教程如何防止高手使用缓冲区溢出?1433端口路由器1433端口怎么开启百度手写百度为什么没有了在线手写输入法畅想中国畅想中国发展前景数据库损坏数据库坏了,怎么修复?免费qq空间装扮有办法免费装扮QQ空间吗??虚拟机软件下载谁有虚拟机软件的网址要好用的blogcnblogcn网页无法正常显示,直接跳转http://www.7t7t.com/7?263企业邮箱设置苹果5s一键设置263企业邮箱
过期备案域名查询 景安vps linuxapache虚拟主机 主机 圣迭戈 好玩的桌面 轻博 租空间 本网站服务器在美国 150邮箱 免空 免费活动 酷番云 备案空间 服务器维护 云服务器比较 工信部网站备案查询 日本代理ip 电信主机托管 免备案jsp空间 更多