Minimal HTTP Client Using Native System TLS

A small client for the Hypertext Transfer Protocol (HTTP/1.1 and HTTP/2), over plain connections and over Transport Layer Security (TLS), that uses the operating system's own TLS implementation and certificate trust store instead of a bundled cryptography library or certificate bundle: 'Schannel' on 'Windows', Apple's native TLS on 'macOS', and 'OpenSSL' elsewhere. Provides a total request timeout, cancellation from 'R' with an interrupt, connection reuse, streaming of response bodies to files or callbacks, structured error conditions, and a pluggable transport layer for testing without a network. Intended as a focused alternative to full multi-protocol clients for packages that only need reliable HTTP requests.


zuhttp

R-CMD-check c-core fuzz network coverage

A minimal HTTP/1.1 and HTTP/2 client for R that uses each platform's own TLS stack and trust store — Schannel on Windows, Network.framework with SecTrust on macOS, system OpenSSL elsewhere — rather than bundling cryptography or a CA bundle. One R dependency, its sibling zujson, for JSON.

Install the released version from CRAN:

install.packages("zuhttp")

Or the development version from GitHub:

# install.packages("pak")
pak::pak("pedrobtz/zuhttp")

Every example below is a real request against a public API, and the #> lines are what it actually returns.

library(zuhttp)

r <- zu_get("https://ipwho.is/8.8.8.8")
zu_resp_status(r)
#> [1] 200
zu_resp_json(r)$country
#> [1] "United States"

# Query parameters are encoded for you.
r <- zu_get("https://ipwho.is/8.8.8.8", query = list(fields = "ip,country,city"))
zu_resp_url(r)
#> [1] "https://ipwho.is/8.8.8.8?fields=ip%2Ccountry%2Ccity"
str(zu_resp_json(r))
#> List of 3
#>  $ ip     : chr "8.8.8.8"
#>  $ country: chr "United States"
#>  $ city   : chr "San Jose"

# `json =` serialises the body and sets Content-Type, unless you set it.
r <- zu_post("https://postman-echo.com/post", json = list(name = "Alice", active = TRUE))
str(zu_resp_json(r)$data)
#> List of 2
#>  $ name  : chr "Alice"
#>  $ active: logi TRUE

Learn more

Security

zuhttp has a single maintainer and no inherited security-response process. That is a real risk for security-critical code: if your project cannot accept it, use curl.

To report a vulnerability, open a private security advisory through GitHub, or email the maintainer listed in DESCRIPTION. There is no patch SLA yet; one is a 1.0 requirement.

License

MIT. Vendored components (picohttpparser, a subset of uriparser, and nghttp2's library) keep their own licences; see inst/COPYRIGHTS.

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("zuhttp")

0.1.0 by Pedro Baltazar, 6 hours ago


https://github.com/pedrobtz/zuhttp, https://pedrobtz.github.io/zuhttp/


Report a bug at https://github.com/pedrobtz/zuhttp/issues


Browse source code at https://github.com/cran/zuhttp


Authors: Pedro Baltazar [aut, cre, cph] , Kazuho Oku [cph] (picohttpparser , see inst/COPYRIGHTS) , Tokuhiro Matsuno [cph] (picohttpparser , see inst/COPYRIGHTS) , Daisuke Murase [cph] (picohttpparser , see inst/COPYRIGHTS) , Shigeo Mitsunari [cph] (picohttpparser , see inst/COPYRIGHTS) , Weijia Song [cph] (uriparser , see inst/COPYRIGHTS) , Sebastian Pipping [cph] (uriparser , see inst/COPYRIGHTS) , Tatsuhiro Tsujikawa [cph] (nghttp2 , see inst/COPYRIGHTS) , nghttp2 contributors [cph] (nghttp2 , see inst/COPYRIGHTS) , sfparse contributors [cph] (sfparse within nghttp2 , see inst/COPYRIGHTS) , nghttp3 contributors [cph] (sfparse within nghttp2 , see inst/COPYRIGHTS)


Documentation:   PDF Manual  


MIT + file LICENSE license


Imports zujson

Suggests curl, parallel, testthat, webfakes, withr, zuhtml, zuxml

System requirements: zlib; and each platform's own TLS stack, which ./configure selects: Schannel on Windows and Network.framework on macOS, both part of the operating system, and OpenSSL >= 1.1.1 on other Unix. No certificate bundle is shipped: the system trust store is used everywhere.


See at CRAN