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
Sharktech 鲨鱼机房商家我们是不是算比较熟悉的,因为有很多的服务商渠道的高防服务器都是拿他们家的机器然后部署高防VPS主机的,不过这几年Sharktech商家有自己直接销售云服务器产品,比如看到有新增公有云主机有促销活动,一般有人可能买回去自己搭建虚拟主机拆分销售的,有的也是自用的。有看到不少网友在分享到鲨鱼机房商家促销活动期间,有赠送开通公有云主机$50,可以购买最低配置的,$49/月的...
Hostigger 主机商在前面的文章中也有介绍过几次,这个商家运营时间是有一些年份,只不过在我们圈内好像之前出现的次数不多。最近这段时间商家有提供不限流量的VPS主机,逐渐的慢慢被人认识到。在前面的介绍到他们提供的机房还是比较多的,比如土耳其、美国等。今天看到Hostigger 商家居然改动挺大的,原来蛮好的域名居然这次连带官方域名都更换掉去掉一个G(Hostiger )。估摸着这个域名也是之前...
今天早上相比很多网友和一样收到来自Linode的庆祝18周年的邮件信息。和往年一样,他们会回顾在过去一年中的成绩,以及在未来准备改进的地方。虽然目前Linode商家没有提供以前JP1优化线路的机房,但是人家一直跟随自己的脚步在走,确实在云服务器市场上有自己的立足之地。我们看看过去一年中Linode的成就:第一、承诺投入 100,000 美元来帮助具有社会意识的非营利组织,促进有价值的革新。第二、发...
404notfound为你推荐
吴晓波频道买粉《吴晓波频道》《罗辑思维》《专栏精粹》怎么评价?自助建站自助建站哪个平台最好?网站联盟网站联盟的运作流程ps抠图技巧ps中怎么抠图?ps抠图技巧photoshop最基本的抠图方法和技巧!安卓应用平台有没有什么安卓游戏都能找到的应用商店或者游戏中心数据库损坏数据库坏了怎么办奇虎论坛360有论坛中心?人人逛街人人逛街评论怎么不显示链接了?好像4月28日就不能显示了。是什么原因呢?免费qq空间装扮有办法免费装扮QQ空间吗??
北京主机租用 域名商 uk2 paypal认证 火车票抢票攻略 国内php空间 亚洲小于500m 免费网站申请 空间技术网 四核服务器 怎么建立邮箱 东莞idc 太原联通测速 smtp服务器地址 登陆qq空间 阿里dns cdn服务 深圳主机托管 月付空间 web是什么意思 更多