httpcode

library("knitr")
hook_output <- knitr::knit_hooks$get("output")
knitr::knit_hooks$set(output = function(x, options) {
   lines <- options$output.lines
   if (is.null(lines)) {
     return(hook_output(x, options))  # pass to default hook
   }
   x <- unlist(strsplit(x, "\n"))
   more <- "..."
   if (length(lines)==1) {        # first n lines
     if (length(x) > lines) {
       # truncate the output, but add ....
       x <- c(head(x, lines), more)
     }
   } else {
     x <- c(if (abs(lines[1])>1) more else NULL,
            x[lines],
            if (length(x)>lines[abs(length(lines))]) more else NULL
           )
   }
   # paste these lines together
   x <- paste(c(x, ""), collapse = "\n")
   hook_output(x, options)
 })

knitr::opts_chunk$set(
  warning = FALSE,
  message = FALSE,
  collapse = TRUE,
  comment = "#>"
)

cran checks R-check codecov rstudio mirror downloads cran version

httpcode is a tiny R package to search for and show http code messages and description. It's a port of the Python httpcode (https://github.com/rspivak/httpcode) library.

httpcode has no dependencies.

Follows RFC 2616 (https://www.ietf.org/rfc/rfc2616.txt), and for additional codes following RFC 6585 (https://tools.ietf.org/html/rfc6585).

Structure of information for each status code:

Installation

Stable version

install.packages("httpcode")

Development version

install.packages("pak")
pak::pkg_install("sckott/httpcode")
library("httpcode")

Search by http code

http_code(100)
http_code(400)
http_code(503)
http_code(999)

Get verbose status code description

http_code(100, verbose = TRUE)
http_code(400, verbose = TRUE)

Fuzzy code search

http_code('1xx')
http_code('3xx')
http_code('30[12]')
http_code('30[34]')

Search by message

http_search("request")
http_search("forbidden")
http_search("too")
http_search("birds")

Bugs/features?

See issues

Code of Conduct

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.



sckott/httpcode documentation built on May 19, 2023, 10:49 p.m.