httping

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

cran checks R-check rstudio mirror downloads cran version

httping is a tiny R package to Ping urls to time requests. It's a port of the Ruby gem httping.

Install

CRAN stable version

install.packages("httping")

Development version from Github

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

Pass any httr request to time

A GET request

GET("https://google.com") %>% time(count = 3)

A POST request

POST("https://mockbin.com/request", body = "A simple text string") %>% time(count = 3)

The return object is a list with slots for all the httr response objects, the times for each request, and the average times. The number of requests, and the delay between requests are included as attributes.

res <- GET("http://google.com") %>% time(count = 3)
attributes(res)

Or print a summary of a response, gives more detail

res %>% summary()

Messages are printed using cat, so you can suppress those using verbose=FALSE, like

GET("https://google.com") %>% time(count = 3, verbose = FALSE)

Ping an endpoint

This function is a bit different, accepts a url as first parameter, but can accept any args passed on to httr verb functions, like GET, POST, etc.

"https://google.com" %>% ping()

Or pass in additional arguments to modify request

"https://google.com" %>% ping(config = verbose())

Meta



sckott/httping documentation built on Nov. 6, 2022, 8:15 p.m.