Binary files /tmp/tmpkh6hg6xy/vRTD95p90d/r-cran-crul-1.3+dfsg/build/vignette.rds and /tmp/tmpkh6hg6xy/UldEckbj3J/r-cran-crul-1.4.0+dfsg/build/vignette.rds differ diff -Nru r-cran-crul-1.3+dfsg/debian/changelog r-cran-crul-1.4.0+dfsg/debian/changelog --- r-cran-crul-1.3+dfsg/debian/changelog 2022-09-15 07:38:45.000000000 +0000 +++ r-cran-crul-1.4.0+dfsg/debian/changelog 2023-06-12 17:34:36.000000000 +0000 @@ -1,3 +1,10 @@ +r-cran-crul (1.4.0+dfsg-1) unstable; urgency=medium + + * New upstream version + * Standards-Version: 4.6.2 (routine-update) + + -- Andreas Tille Mon, 12 Jun 2023 19:34:36 +0200 + r-cran-crul (1.3+dfsg-1) unstable; urgency=medium * New upstream version diff -Nru r-cran-crul-1.3+dfsg/debian/control r-cran-crul-1.4.0+dfsg/debian/control --- r-cran-crul-1.3+dfsg/debian/control 2022-09-15 07:38:45.000000000 +0000 +++ r-cran-crul-1.4.0+dfsg/debian/control 2023-06-12 17:34:36.000000000 +0000 @@ -13,7 +13,7 @@ r-cran-httpcode, r-cran-jsonlite, r-cran-mime -Standards-Version: 4.6.1 +Standards-Version: 4.6.2 Vcs-Browser: https://salsa.debian.org/r-pkg-team/r-cran-crul Vcs-Git: https://salsa.debian.org/r-pkg-team/r-cran-crul.git Homepage: https://cran.r-project.org/package=crul diff -Nru r-cran-crul-1.3+dfsg/DESCRIPTION r-cran-crul-1.4.0+dfsg/DESCRIPTION --- r-cran-crul-1.3+dfsg/DESCRIPTION 2022-09-03 06:30:10.000000000 +0000 +++ r-cran-crul-1.4.0+dfsg/DESCRIPTION 2023-05-17 07:30:02.000000000 +0000 @@ -6,7 +6,7 @@ The package name is a play on curl, the widely used command line tool for HTTP, and this package is built on top of the R package 'curl', an interface to 'libcurl' (). -Version: 1.3 +Version: 1.4.0 License: MIT + file LICENSE Authors@R: c( person("Scott", "Chamberlain", role = c("aut", "cre"), @@ -24,14 +24,14 @@ Suggests: testthat, roxygen2 (>= 7.1.1), fauxpas (>= 0.1.0), webmockr (>= 0.1.0), knitr, rmarkdown VignetteBuilder: knitr -RoxygenNote: 7.2.1 +RoxygenNote: 7.2.3 X-schema.org-applicationCategory: Web X-schema.org-keywords: http, https, API, web-services, curl, download, libcurl, async, mocking, caching X-schema.org-isPartOf: https://ropensci.org NeedsCompilation: no -Packaged: 2022-09-03 05:09:14 UTC; sckott +Packaged: 2023-05-13 02:57:08 UTC; sckott Author: Scott Chamberlain [aut, cre] () Maintainer: Scott Chamberlain Repository: CRAN -Date/Publication: 2022-09-03 06:30:10 UTC +Date/Publication: 2023-05-17 07:30:02 UTC diff -Nru r-cran-crul-1.3+dfsg/inst/doc/async.Rmd r-cran-crul-1.4.0+dfsg/inst/doc/async.Rmd --- r-cran-crul-1.3+dfsg/inst/doc/async.Rmd 2021-08-16 21:05:01.000000000 +0000 +++ r-cran-crul-1.4.0+dfsg/inst/doc/async.Rmd 2023-05-10 21:56:03.000000000 +0000 @@ -1,7 +1,7 @@ --- title: 3. async with crul author: Scott Chamberlain -date: "2020-07-09" +date: "2023-05-10" output: rmarkdown::html_vignette vignette: > %\VignetteIndexEntry{3. async with crul} @@ -44,9 +44,9 @@ ```r (cc <- Async$new( urls = c( - 'https://httpbin.org/get?a=5', - 'https://httpbin.org/get?a=5&b=6', - 'https://httpbin.org/ip' + 'https://hb.opencpu.org/get?a=5', + 'https://hb.opencpu.org/get?a=5&b=6', + 'https://hb.opencpu.org/ip' ) )) #> @@ -55,9 +55,9 @@ #> auth: #> headers: #> urls: (n: 3) -#> https://httpbin.org/get?a=5 -#> https://httpbin.org/get?a=5&b=6 -#> https://httpbin.org/ip +#> https://hb.opencpu.org/get?a=5 +#> https://hb.opencpu.org/get?a=5&b=6 +#> https://hb.opencpu.org/ip ``` Make request with any HTTP method @@ -65,52 +65,11 @@ ```r (res <- cc$get()) -#> [[1]] -#> -#> url: https://httpbin.org/get?a=5 -#> request_headers: -#> response_headers: -#> status: HTTP/2 200 -#> date: Thu, 09 Jul 2020 20:14:45 GMT -#> content-type: application/json -#> content-length: 400 -#> server: gunicorn/19.9.0 -#> access-control-allow-origin: * -#> access-control-allow-credentials: true -#> params: -#> a: 5 -#> status: 200 -#> -#> [[2]] -#> -#> url: https://httpbin.org/get?a=5&b=6 -#> request_headers: -#> response_headers: -#> status: HTTP/2 200 -#> date: Thu, 09 Jul 2020 20:14:45 GMT -#> content-type: application/json -#> content-length: 419 -#> server: gunicorn/19.9.0 -#> access-control-allow-origin: * -#> access-control-allow-credentials: true -#> params: -#> a: 5 -#> b: 6 -#> status: 200 -#> -#> [[3]] -#> -#> url: https://httpbin.org/ip -#> request_headers: -#> response_headers: -#> status: HTTP/2 200 -#> date: Thu, 09 Jul 2020 20:14:45 GMT -#> content-type: application/json -#> content-length: 31 -#> server: gunicorn/19.9.0 -#> access-control-allow-origin: * -#> access-control-allow-credentials: true -#> status: 200 +#> async responses +#> status code - url (N=3; printing up to 10) +#> 200 - https://hb.opencpu.org/get?a=5 +#> 200 - https://hb.opencpu.org/get?a=5&b=6 +#> 200 - https://hb.opencpu.org/ip ``` You get back a list matching length of the number of input URLs @@ -120,11 +79,11 @@ ```r res[[1]]$url -#> [1] "https://httpbin.org/get?a=5" +#> [1] "https://hb.opencpu.org/get?a=5" res[[1]]$success() #> [1] TRUE res[[1]]$parse("UTF-8") -#> [1] "{\n \"args\": {\n \"a\": \"5\"\n }, \n \"headers\": {\n \"Accept\": \"application/json, text/xml, application/xml, */*\", \n \"Accept-Encoding\": \"gzip, deflate\", \n \"Host\": \"httpbin.org\", \n \"User-Agent\": \"R (4.0.2 x86_64-apple-darwin17.0 x86_64 darwin17.0)\", \n \"X-Amzn-Trace-Id\": \"Root=1-5f077ab5-686fd087166386a10fe80f25\"\n }, \n \"origin\": \"24.21.229.59\", \n \"url\": \"https://httpbin.org/get?a=5\"\n}\n" +#> [1] "{\n \"args\": {\n \"a\": \"5\"\n }, \n \"headers\": {\n \"Accept\": \"application/json, text/xml, application/xml, */*\", \n \"Accept-Encoding\": \"gzip, deflate\", \n \"Connection\": \"close\", \n \"Host\": \"httpbin:8080\", \n \"User-Agent\": \"R (4.2.3 aarch64-apple-darwin20 aarch64 darwin20)\"\n }, \n \"origin\": \"172.18.0.4\", \n \"url\": \"http://httpbin:8080/get?a=5\"\n}\n" ``` Or apply access/method calls across many results, e.g., parse all results @@ -133,13 +92,13 @@ ```r lapply(res, function(z) z$parse("UTF-8")) #> [[1]] -#> [1] "{\n \"args\": {\n \"a\": \"5\"\n }, \n \"headers\": {\n \"Accept\": \"application/json, text/xml, application/xml, */*\", \n \"Accept-Encoding\": \"gzip, deflate\", \n \"Host\": \"httpbin.org\", \n \"User-Agent\": \"R (4.0.2 x86_64-apple-darwin17.0 x86_64 darwin17.0)\", \n \"X-Amzn-Trace-Id\": \"Root=1-5f077ab5-686fd087166386a10fe80f25\"\n }, \n \"origin\": \"24.21.229.59\", \n \"url\": \"https://httpbin.org/get?a=5\"\n}\n" +#> [1] "{\n \"args\": {\n \"a\": \"5\"\n }, \n \"headers\": {\n \"Accept\": \"application/json, text/xml, application/xml, */*\", \n \"Accept-Encoding\": \"gzip, deflate\", \n \"Connection\": \"close\", \n \"Host\": \"httpbin:8080\", \n \"User-Agent\": \"R (4.2.3 aarch64-apple-darwin20 aarch64 darwin20)\"\n }, \n \"origin\": \"172.18.0.4\", \n \"url\": \"http://httpbin:8080/get?a=5\"\n}\n" #> #> [[2]] -#> [1] "{\n \"args\": {\n \"a\": \"5\", \n \"b\": \"6\"\n }, \n \"headers\": {\n \"Accept\": \"application/json, text/xml, application/xml, */*\", \n \"Accept-Encoding\": \"gzip, deflate\", \n \"Host\": \"httpbin.org\", \n \"User-Agent\": \"R (4.0.2 x86_64-apple-darwin17.0 x86_64 darwin17.0)\", \n \"X-Amzn-Trace-Id\": \"Root=1-5f077ab5-0c5caed1b0cac8d405458e4e\"\n }, \n \"origin\": \"24.21.229.59\", \n \"url\": \"https://httpbin.org/get?a=5&b=6\"\n}\n" +#> [1] "{\n \"args\": {\n \"a\": \"5\", \n \"b\": \"6\"\n }, \n \"headers\": {\n \"Accept\": \"application/json, text/xml, application/xml, */*\", \n \"Accept-Encoding\": \"gzip, deflate\", \n \"Connection\": \"close\", \n \"Host\": \"httpbin:8080\", \n \"User-Agent\": \"R (4.2.3 aarch64-apple-darwin20 aarch64 darwin20)\"\n }, \n \"origin\": \"172.18.0.4\", \n \"url\": \"http://httpbin:8080/get?a=5&b=6\"\n}\n" #> #> [[3]] -#> [1] "{\n \"origin\": \"24.21.229.59\"\n}\n" +#> [1] "{\n \"origin\": \"172.18.0.4\"\n}\n" ``` ## varied request async @@ -147,14 +106,14 @@ ```r req1 <- HttpRequest$new( - url = "https://httpbin.org/get?a=5", + url = "https://hb.opencpu.org/get?a=5", opts = list( verbose = TRUE ) ) req1$get() #> get -#> url: https://httpbin.org/get?a=5 +#> url: https://hb.opencpu.org/get?a=5 #> curl options: #> verbose: TRUE #> proxies: @@ -163,11 +122,11 @@ #> progress: FALSE req2 <- HttpRequest$new( - url = "https://httpbin.org/post?a=5&b=6" + url = "https://hb.opencpu.org/post?a=5&b=6" ) req2$post(body = list(a = 5)) #> post -#> url: https://httpbin.org/post?a=5&b=6 +#> url: https://hb.opencpu.org/post?a=5&b=6 #> curl options: #> proxies: #> auth: @@ -177,8 +136,8 @@ (res <- AsyncVaried$new(req1, req2)) #> #> requests: (n: 2) -#> get: https://httpbin.org/get?a=5 -#> post: https://httpbin.org/post?a=5&b=6 +#> get: https://hb.opencpu.org/get?a=5 +#> post: https://hb.opencpu.org/post?a=5&b=6 ``` Make requests asynchronously @@ -193,8 +152,8 @@ ```r res$parse() -#> [1] "{\n \"args\": {\n \"a\": \"5\"\n }, \n \"headers\": {\n \"Accept\": \"application/json, text/xml, application/xml, */*\", \n \"Accept-Encoding\": \"gzip, deflate\", \n \"Host\": \"httpbin.org\", \n \"User-Agent\": \"R (4.0.2 x86_64-apple-darwin17.0 x86_64 darwin17.0)\", \n \"X-Amzn-Trace-Id\": \"Root=1-5f077ab6-74ff987c9d00dd500c8ad920\"\n }, \n \"origin\": \"24.21.229.59\", \n \"url\": \"https://httpbin.org/get?a=5\"\n}\n" -#> [2] "{\n \"args\": {\n \"a\": \"5\", \n \"b\": \"6\"\n }, \n \"data\": \"\", \n \"files\": {}, \n \"form\": {\n \"a\": \"5\"\n }, \n \"headers\": {\n \"Accept\": \"application/json, text/xml, application/xml, */*\", \n \"Accept-Encoding\": \"gzip, deflate\", \n \"Content-Length\": \"137\", \n \"Content-Type\": \"multipart/form-data; boundary=------------------------cb67be38c1a8a084\", \n \"Host\": \"httpbin.org\", \n \"User-Agent\": \"libcurl/7.64.1 r-curl/4.3 crul/0.9.2.93\", \n \"X-Amzn-Trace-Id\": \"Root=1-5f077ab6-d206c2e86f429778e6cb9810\"\n }, \n \"json\": null, \n \"origin\": \"24.21.229.59\", \n \"url\": \"https://httpbin.org/post?a=5&b=6\"\n}\n" +#> [1] "{\n \"args\": {\n \"a\": \"5\"\n }, \n \"headers\": {\n \"Accept\": \"application/json, text/xml, application/xml, */*\", \n \"Accept-Encoding\": \"gzip, deflate\", \n \"Connection\": \"close\", \n \"Host\": \"httpbin:8080\", \n \"User-Agent\": \"R (4.2.3 aarch64-apple-darwin20 aarch64 darwin20)\"\n }, \n \"origin\": \"172.18.0.4\", \n \"url\": \"http://httpbin:8080/get?a=5\"\n}\n" +#> [2] "{\n \"args\": {\n \"a\": \"5\", \n \"b\": \"6\"\n }, \n \"data\": \"\", \n \"files\": {}, \n \"form\": {\n \"a\": \"5\"\n }, \n \"headers\": {\n \"Accept\": \"application/json, text/xml, application/xml, */*\", \n \"Accept-Encoding\": \"gzip, deflate\", \n \"Connection\": \"close\", \n \"Content-Length\": \"137\", \n \"Content-Type\": \"multipart/form-data; boundary=------------------------389c6ab199efc7cd\", \n \"Host\": \"httpbin:8080\", \n \"User-Agent\": \"libcurl/7.87.0 r-curl/5.0.0 crul/1.3.9100\"\n }, \n \"json\": null, \n \"origin\": \"172.18.0.4\", \n \"url\": \"http://httpbin:8080/post?a=5&b=6\"\n}\n" ``` @@ -208,12 +167,12 @@ #> "headers": { #> "Accept": "application/json, text/xml, application/xml, */*", #> "Accept-Encoding": "gzip, deflate", -#> "Host": "httpbin.org", -#> "User-Agent": "R (4.0.2 x86_64-apple-darwin17.0 x86_64 darwin17.0)", -#> "X-Amzn-Trace-Id": "Root=1-5f077ab6-74ff987c9d00dd500c8ad920" +#> "Connection": "close", +#> "Host": "httpbin:8080", +#> "User-Agent": "R (4.2.3 aarch64-apple-darwin20 aarch64 darwin20)" #> }, -#> "origin": "24.21.229.59", -#> "url": "https://httpbin.org/get?a=5" +#> "origin": "172.18.0.4", +#> "url": "http://httpbin:8080/get?a=5" #> } #> #> @@ -233,15 +192,15 @@ #> "headers": { #> "Accept": "application/json, text/xml, application/xml, */*", #> "Accept-Encoding": "gzip, deflate", +#> "Connection": "close", #> "Content-Length": "137", -#> "Content-Type": "multipart/form-data; boundary=------------------------cb67be38c1a8a084", -#> "Host": "httpbin.org", -#> "User-Agent": "libcurl/7.64.1 r-curl/4.3 crul/0.9.2.93", -#> "X-Amzn-Trace-Id": "Root=1-5f077ab6-d206c2e86f429778e6cb9810" +#> "Content-Type": "multipart/form-data; boundary=------------------------389c6ab199efc7cd", +#> "Host": "httpbin:8080", +#> "User-Agent": "libcurl/7.87.0 r-curl/5.0.0 crul/1.3.9100" #> }, #> "json": null, -#> "origin": "24.21.229.59", -#> "url": "https://httpbin.org/post?a=5&b=6" +#> "origin": "172.18.0.4", +#> "url": "http://httpbin:8080/post?a=5&b=6" #> } #> ``` diff -Nru r-cran-crul-1.3+dfsg/inst/doc/best-practices-api-packages.Rmd r-cran-crul-1.4.0+dfsg/inst/doc/best-practices-api-packages.Rmd --- r-cran-crul-1.3+dfsg/inst/doc/best-practices-api-packages.Rmd 2021-08-16 21:05:23.000000000 +0000 +++ r-cran-crul-1.4.0+dfsg/inst/doc/best-practices-api-packages.Rmd 2023-05-10 21:56:03.000000000 +0000 @@ -1,7 +1,7 @@ --- title: 5. API package best practices author: Scott Chamberlain -date: "2021-08-16" +date: "2023-05-10" output: rmarkdown::html_vignette vignette: > %\VignetteIndexEntry{5. API package best practices} @@ -63,7 +63,7 @@ ```r -x <- xGET("https://httpbin.org", "get", args = list(foo = "bar")) +x <- xGET("https://hb.opencpu.org", "get", args = list(foo = "bar")) # parse the JSON to a list jsonlite::fromJSON(x) # more parsing @@ -100,7 +100,7 @@ ```r -con <- HttpClient$new("https://httpbin.org/status/404") +con <- HttpClient$new("https://hb.opencpu.org/status/404") res <- con$get() ``` @@ -252,5 +252,5 @@ [webmockr]: https://github.com/ropensci/webmockr [vcr]: https://github.com/ropensci/vcr [httr]: https://github.com/r-lib/httr -[fauxpas]: https://github.com/ropensci/fauxpas +[fauxpas]: https://github.com/sckott/fauxpas [book]: https://books.ropensci.org/http-testing/ diff -Nru r-cran-crul-1.3+dfsg/inst/doc/choosing-a-client.Rmd r-cran-crul-1.4.0+dfsg/inst/doc/choosing-a-client.Rmd --- r-cran-crul-1.3+dfsg/inst/doc/choosing-a-client.Rmd 2022-08-19 15:05:40.000000000 +0000 +++ r-cran-crul-1.4.0+dfsg/inst/doc/choosing-a-client.Rmd 2023-05-10 21:56:02.000000000 +0000 @@ -1,7 +1,7 @@ --- title: 6. Choosing a HTTP request class author: Scott Chamberlain -date: "2020-07-13" +date: "2023-05-10" output: rmarkdown::html_vignette vignette: > %\VignetteIndexEntry{6. Choosing a HTTP request class} @@ -18,8 +18,8 @@ |HttpClient|all|no|[bcdata][],[chirps][],[duckduckr][],[gfonts][],[mindicador][],[nsapi][],[tradestatistics][],[viafr][]| |Paginator|all except retry|no|---| |ok|head,get|no|[dams][]| -|Async|all except retry|yes|[fulltext][],[rdryad][],[rnoaa][]| -|AsyncVaried|all except retry|yes|[rcrossref][],[taxize][],[rcitoid][],[mstrio][]| +|Async|all except retry|yes|[rdryad][],[rnoaa][]| +|AsyncVaried|all except retry|yes|[rcrossref][],[taxize][],[mstrio][]| |AsyncQueue|all except retry|yes|---| **HttpClient** is the main class for doing synchronous HTTP requests. It supports all HTTP verbs including retry. It was the first class in this package. See also `crul::ok()`, which builds on this class. @@ -50,11 +50,9 @@ [nsapi]: https://rmhogervorst.nl/nsapi/ [tradestatistics]: https://docs.ropensci.org/tradestatistics/ [viafr]: https://github.com/stefanieschneider/viafr -[fulltext]:https://docs.ropensci.org/fulltext/ [rdryad]: https://docs.ropensci.org/rdryad/ [rnoaa]: https://docs.ropensci.org/rnoaa/ [rcrossref]: https://docs.ropensci.org/rcrossref/ [taxize]: https://docs.ropensci.org/taxize/ -[rcitoid]: https://docs.ropensci.org/rcitoid/ [mstrio]: https://cran.r-project.org/package=mstrio [dams]: https://jsta.github.io/dams/ diff -Nru r-cran-crul-1.3+dfsg/inst/doc/crul.Rmd r-cran-crul-1.4.0+dfsg/inst/doc/crul.Rmd --- r-cran-crul-1.3+dfsg/inst/doc/crul.Rmd 2021-08-16 21:05:01.000000000 +0000 +++ r-cran-crul-1.4.0+dfsg/inst/doc/crul.Rmd 2023-05-10 21:55:58.000000000 +0000 @@ -1,7 +1,7 @@ --- title: 1. crul introduction author: Scott Chamberlain -date: "2020-07-10" +date: "2023-05-10" output: rmarkdown::html_vignette vignette: > %\VignetteIndexEntry{1. crul introduction} @@ -26,7 +26,8 @@ ```r -remotes::install_github("ropensci/crul") +install.packages("pak") +pak::pkg_install("ropensci/crul") ``` @@ -41,7 +42,7 @@ ```r (x <- HttpClient$new( - url = "https://httpbin.org", + url = "https://hb.opencpu.org", opts = list( timeout = 1 ), @@ -50,7 +51,7 @@ ) )) #> -#> url: https://httpbin.org +#> url: https://hb.opencpu.org #> curl options: #> timeout: 1 #> proxies: @@ -86,7 +87,7 @@ curl options. Here, we'll do a __GET__ request on the route `/get` on our base url -`https://httpbin.org` (the full url is then `https://httpbin.org/get`) +`https://hb.opencpu.org` (the full url is then `https://hb.opencpu.org/get`) ```r @@ -116,16 +117,15 @@ #> [76] 6c 69 63 61 74 69 6f 6e 2f 6a 73 6f 6e 2c 20 74 65 78 74 2f 78 6d 6c 2c 20 #> [101] 61 70 70 6c 69 63 61 74 69 6f 6e 2f 78 6d 6c 2c 20 2a 2f 2a 22 2c 20 0a 20 #> [126] 20 20 20 22 41 63 63 65 70 74 2d 45 6e 63 6f 64 69 6e 67 22 3a 20 22 67 7a -#> [151] 69 70 2c 20 64 65 66 6c 61 74 65 22 2c 20 0a 20 20 20 20 22 48 6f 73 74 22 -#> [176] 3a 20 22 68 74 74 70 62 69 6e 2e 6f 72 67 22 2c 20 0a 20 20 20 20 22 55 73 -#> [201] 65 72 2d 41 67 65 6e 74 22 3a 20 22 6c 69 62 63 75 72 6c 2f 37 2e 36 34 2e -#> [226] 31 20 72 2d 63 75 72 6c 2f 34 2e 33 20 63 72 75 6c 2f 30 2e 39 2e 34 2e 39 -#> [251] 31 22 2c 20 0a 20 20 20 20 22 58 2d 41 6d 7a 6e 2d 54 72 61 63 65 2d 49 64 -#> [276] 22 3a 20 22 52 6f 6f 74 3d 31 2d 35 66 30 38 64 36 63 65 2d 61 61 32 30 39 -#> [301] 37 30 64 63 62 63 31 33 64 30 61 37 65 38 66 32 35 65 36 22 0a 20 20 7d 2c -#> [326] 20 0a 20 20 22 6f 72 69 67 69 6e 22 3a 20 22 32 34 2e 32 31 2e 32 32 39 2e -#> [351] 35 39 22 2c 20 0a 20 20 22 75 72 6c 22 3a 20 22 68 74 74 70 73 3a 2f 2f 68 -#> [376] 74 74 70 62 69 6e 2e 6f 72 67 2f 67 65 74 22 0a 7d 0a +#> [151] 69 70 2c 20 64 65 66 6c 61 74 65 22 2c 20 0a 20 20 20 20 22 43 6f 6e 6e 65 +#> [176] 63 74 69 6f 6e 22 3a 20 22 63 6c 6f 73 65 22 2c 20 0a 20 20 20 20 22 48 6f +#> [201] 73 74 22 3a 20 22 68 74 74 70 62 69 6e 3a 38 30 38 30 22 2c 20 0a 20 20 20 +#> [226] 20 22 55 73 65 72 2d 41 67 65 6e 74 22 3a 20 22 6c 69 62 63 75 72 6c 2f 37 +#> [251] 2e 38 37 2e 30 20 72 2d 63 75 72 6c 2f 35 2e 30 2e 30 20 63 72 75 6c 2f 31 +#> [276] 2e 33 2e 39 31 30 30 22 0a 20 20 7d 2c 20 0a 20 20 22 6f 72 69 67 69 6e 22 +#> [301] 3a 20 22 31 37 32 2e 31 38 2e 30 2e 34 22 2c 20 0a 20 20 22 75 72 6c 22 3a +#> [326] 20 22 68 74 74 70 3a 2f 2f 68 74 74 70 62 69 6e 3a 38 30 38 30 2f 67 65 74 +#> [351] 22 0a 7d 0a ``` HTTP method @@ -142,7 +142,7 @@ ```r res$request_headers #> $`User-Agent` -#> [1] "libcurl/7.64.1 r-curl/4.3 crul/0.9.4.91" +#> [1] "libcurl/7.87.0 r-curl/5.0.0 crul/1.3.9100" #> #> $`Accept-Encoding` #> [1] "gzip, deflate" @@ -160,25 +160,34 @@ ```r res$response_headers #> $status -#> [1] "HTTP/2 200 " +#> [1] "HTTP/1.1 200 OK" +#> +#> $server +#> [1] "nginx/1.20.2" #> #> $date -#> [1] "Fri, 10 Jul 2020 20:59:58 GMT" +#> [1] "Wed, 10 May 2023 21:55:58 GMT" #> #> $`content-type` #> [1] "application/json" #> #> $`content-length` -#> [1] "393" +#> [1] "354" #> -#> $server -#> [1] "gunicorn/19.9.0" +#> $connection +#> [1] "keep-alive" #> #> $`access-control-allow-origin` #> [1] "*" #> #> $`access-control-allow-credentials` #> [1] "true" +#> +#> $`x-powered-by` +#> [1] "Flask" +#> +#> $`x-processed-time` +#> [1] "0" ``` All response headers, including intermediate headers, if any @@ -188,25 +197,34 @@ res$response_headers_all #> [[1]] #> [[1]]$status -#> [1] "HTTP/2 200 " +#> [1] "HTTP/1.1 200 OK" +#> +#> [[1]]$server +#> [1] "nginx/1.20.2" #> #> [[1]]$date -#> [1] "Fri, 10 Jul 2020 20:59:58 GMT" +#> [1] "Wed, 10 May 2023 21:55:58 GMT" #> #> [[1]]$`content-type` #> [1] "application/json" #> #> [[1]]$`content-length` -#> [1] "393" +#> [1] "354" #> -#> [[1]]$server -#> [1] "gunicorn/19.9.0" +#> [[1]]$connection +#> [1] "keep-alive" #> #> [[1]]$`access-control-allow-origin` #> [1] "*" #> #> [[1]]$`access-control-allow-credentials` #> [1] "true" +#> +#> [[1]]$`x-powered-by` +#> [1] "Flask" +#> +#> [[1]]$`x-processed-time` +#> [1] "0" ``` And you can parse the content with a provided function: @@ -214,7 +232,7 @@ ```r res$parse() -#> [1] "{\n \"args\": {}, \n \"headers\": {\n \"A\": \"hello world\", \n \"Accept\": \"application/json, text/xml, application/xml, */*\", \n \"Accept-Encoding\": \"gzip, deflate\", \n \"Host\": \"httpbin.org\", \n \"User-Agent\": \"libcurl/7.64.1 r-curl/4.3 crul/0.9.4.91\", \n \"X-Amzn-Trace-Id\": \"Root=1-5f08d6ce-aa20970dcbc13d0a7e8f25e6\"\n }, \n \"origin\": \"24.21.229.59\", \n \"url\": \"https://httpbin.org/get\"\n}\n" +#> [1] "{\n \"args\": {}, \n \"headers\": {\n \"A\": \"hello world\", \n \"Accept\": \"application/json, text/xml, application/xml, */*\", \n \"Accept-Encoding\": \"gzip, deflate\", \n \"Connection\": \"close\", \n \"Host\": \"httpbin:8080\", \n \"User-Agent\": \"libcurl/7.87.0 r-curl/5.0.0 crul/1.3.9100\"\n }, \n \"origin\": \"172.18.0.4\", \n \"url\": \"http://httpbin:8080/get\"\n}\n" jsonlite::fromJSON(res$parse()) #> $args #> named list() @@ -229,21 +247,21 @@ #> $headers$`Accept-Encoding` #> [1] "gzip, deflate" #> +#> $headers$Connection +#> [1] "close" +#> #> $headers$Host -#> [1] "httpbin.org" +#> [1] "httpbin:8080" #> #> $headers$`User-Agent` -#> [1] "libcurl/7.64.1 r-curl/4.3 crul/0.9.4.91" -#> -#> $headers$`X-Amzn-Trace-Id` -#> [1] "Root=1-5f08d6ce-aa20970dcbc13d0a7e8f25e6" +#> [1] "libcurl/7.87.0 r-curl/5.0.0 crul/1.3.9100" #> #> #> $origin -#> [1] "24.21.229.59" +#> [1] "172.18.0.4" #> #> $url -#> [1] "https://httpbin.org/get" +#> [1] "http://httpbin:8080/get" ``` With the `HttpClient` object, which holds any configuration stuff @@ -263,12 +281,12 @@ ```r -x <- HttpClient$new(url = "https://httpbin.org") +x <- HttpClient$new(url = "https://hb.opencpu.org") f <- tempfile() res <- x$get(disk = f) # when using write to disk, content is a path res$content -#> [1] "/var/folders/fc/n7g_vrvn0sx_st0p8lxb3ts40000gn/T//RtmppSPqIf/file20b5651a4a3a" +#> [1] "/var/folders/vw/4nm3x1ld0_jgmqy6_yf6pz3c0000gn/T//RtmpZ9O9vQ/file17033155d5263" ``` Read lines @@ -276,25 +294,25 @@ ```r readLines(res$content, n = 10) -#> [1] "" -#> [2] "" -#> [3] "" -#> [4] "" -#> [5] " " -#> [6] " httpbin.org" -#> [7] " [8] " rel=\"stylesheet\">" -#> [9] " " -#> [10] " " +#> [1] "" +#> [2] "" +#> [3] "" +#> [4] " " +#> [5] " " +#> [6] " httpbin(1): HTTP Client Testing Service" +#> [7] "