fauxpas does http errors
R Makefile
Latest commit 1fd8f7b Nov 18, 2016 @sckott sckott add full footer to readme
Permalink
Failed to load latest commit information.
R fixed children fxns to use verbose template when do_verbose is called Nov 15, 2016
extra
man-roxygen changed error_* to http*, add param template Nov 15, 2016
man fixed children fxns to use verbose template when do_verbose is called Nov 15, 2016
tests
.Rbuildignore dont rbuildignore news.md Nov 15, 2016
.gitignore
.travis.yml first commit Apr 13, 2016
CONDUCT.md first commit Apr 13, 2016
DESCRIPTION
LICENSE
Makefile
NAMESPACE changed error_* to http*, add param template Nov 15, 2016
NEWS.md added new and cran comments, ready to go, bumped to v0.1 Nov 15, 2016
README.Rmd add full footer to readme Nov 18, 2016
README.md add full footer to readme Nov 18, 2016
cran-comments.md added new and cran comments, ready to go, bumped to v0.1 Nov 15, 2016
fauxpas.Rproj

README.md

fauxpas

Build Status cran version rstudio mirror downloads

fauxpas does http errors

  • HTTP error classes more in line with Ruby/Python/Etc.
  • An error class for each HTTP status in case a user wants to be specific to an HTTP status code, and general purpose handlers for any error
  • Work with any of the major R http clients: crul, curl, httr, (maybe RCurl later)
  • Provide flexiblity for what to do on an HTTP error, including custom functions and message templates

Info Links:

Install

CRAN version

install.packages("fauxpas")

Dev version

devtools::install_github("ropenscilabs/fauxpas")
library("fauxpas")

use with crul

library("crul")
cli <- HttpClient$new("https://httpbin.org/status/414")
res <- cli$get()
http(res)
#> Error: Request-URI Too Long (HTTP 414).
http414(res)
#> Error: Request-URI Too Long (HTTP 414).
x <- HTTPRequestURITooLong$new()
x$do_verbose(res)
#> Error: Request-URI Too Long (HTTP 414).
#> - The server is refusing to service the request because the Request-URI is
#>    longer than the server is willing to interpret. This rare condition is only likely
#>    to occur when a client has improperly converted a POST request to a GET request
#>    with long query information, when the client has descended into a URI black hole
#>    of redirection (e.g., a redirected URI prefix that points to a suffix of itself),
#>    or when the server is under attack by a client attempting to exploit security
#>    holes present in some servers using fixed-length buffers for reading or
#>    manipulating the Request-URI.

use with curl

library("curl")
h <- curl::new_handle()
curl::handle_setopt(h)
resp <- curl::curl_fetch_memory("https://httpbin.org/status/404", h)
http(resp)
#> Error: Not Found (HTTP 404).
http404(resp)
#> Error: Not Found (HTTP 404).
x <- HTTPNotFound$new()
x$do_verbose(resp)
#> Error:  Not Found (HTTP 404).
#>  - The server has not found anything matching the Request-URI. No indication is
#> given of whether the condition is temporary or permanent. The 410 (Gone) status
#> code SHOULD be used if the server knows, through some internally configurable
#> mechanism, that an old resource is permanently unavailable and has no forwarding
#> address. #> This status code is commonly used when the server does not wish to
#> reveal exactly why the request has been refused, or when no other response is
#> applicable.

use with httr

library("httr")
res <- GET("https://httpbin.org/status/405")
http405(res)
#> Error: Method Not Allowed (HTTP 405).
x <- HTTPMethodNotAllowed$new()
x$do_verbose(res)
#> Error: Method Not Allowed (HTTP 405).
#>  - The method specified in the Request-Line is not allowed for the resource
#> identified by the Request-URI. The response MUST include an Allow header
#> containing a list of valid methods for the requested resource.

Meta

  • Please report any issues or bugs
  • License: MIT
  • Get citation information for fauxpas in R doing citation(package = 'fauxpas')
  • Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.

rofooter