Skip to content

Commit

Permalink
replace httpbin.org throughout examples/tests/vignettes with https://…
Browse files Browse the repository at this point in the history
  • Loading branch information
sckott committed May 10, 2023
1 parent f4d23a3 commit b0de342
Show file tree
Hide file tree
Showing 63 changed files with 345 additions and 388 deletions.
16 changes: 8 additions & 8 deletions R/async-queue.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,22 @@
#' @examples \dontrun{
#' # Using sleep (note this works with retry requests)
#' reqlist <- list(
#' HttpRequest$new(url = "https://httpbin.org/get")$get(),
#' HttpRequest$new(url = "https://httpbin.org/post")$post(),
#' HttpRequest$new(url = "https://httpbin.org/put")$put(),
#' HttpRequest$new(url = "https://httpbin.org/delete")$delete(),
#' HttpRequest$new(url = "https://httpbin.org/get?g=5")$get(),
#' HttpRequest$new(url = "https://hb.opencpu.org/get")$get(),
#' HttpRequest$new(url = "https://hb.opencpu.org/post")$post(),
#' HttpRequest$new(url = "https://hb.opencpu.org/put")$put(),
#' HttpRequest$new(url = "https://hb.opencpu.org/delete")$delete(),
#' HttpRequest$new(url = "https://hb.opencpu.org/get?g=5")$get(),
#' HttpRequest$new(
#' url = "https://httpbin.org/post")$post(body = list(y = 9)),
#' url = "https://hb.opencpu.org/post")$post(body = list(y = 9)),
#' HttpRequest$new(
#' url = "https://httpbin.org/get")$get(query = list(hello = "world")),
#' url = "https://hb.opencpu.org/get")$get(query = list(hello = "world")),
#' HttpRequest$new(url = "https://ropensci.org")$get(),
#' HttpRequest$new(url = "https://ropensci.org/about")$get(),
#' HttpRequest$new(url = "https://ropensci.org/packages")$get(),
#' HttpRequest$new(url = "https://ropensci.org/community")$get(),
#' HttpRequest$new(url = "https://ropensci.org/blog")$get(),
#' HttpRequest$new(url = "https://ropensci.org/careers")$get(),
#' HttpRequest$new(url = "https://httpbin.org/status/404")$retry("get")
#' HttpRequest$new(url = "https://hb.opencpu.org/status/404")$retry("get")
#' )
#' out <- AsyncQueue$new(.list = reqlist, bucket_size = 5, sleep = 3)
#' out
Expand Down
30 changes: 15 additions & 15 deletions R/async.R
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
#' @examples \dontrun{
#' cc <- Async$new(
#' urls = c(
#' 'https://httpbin.org/',
#' 'https://httpbin.org/get?a=5',
#' 'https://httpbin.org/get?foo=bar'
#' 'https://hb.opencpu.org/',
#' 'https://hb.opencpu.org/get?a=5',
#' 'https://hb.opencpu.org/get?foo=bar'
#' )
#' )
#' cc
Expand All @@ -43,9 +43,9 @@
#'
#' # curl options/headers with async
#' urls = c(
#' 'https://httpbin.org/',
#' 'https://httpbin.org/get?a=5',
#' 'https://httpbin.org/get?foo=bar'
#' 'https://hb.opencpu.org/',
#' 'https://hb.opencpu.org/get?a=5',
#' 'https://hb.opencpu.org/get?foo=bar'
#' )
#' cc <- Async$new(urls = urls,
#' opts = list(verbose = TRUE),
Expand All @@ -56,7 +56,7 @@
#'
#' # using auth with async
#' dd <- Async$new(
#' urls = rep('https://httpbin.org/basic-auth/user/passwd', 3),
#' urls = rep('https://hb.opencpu.org/basic-auth/user/passwd', 3),
#' auth = auth(user = "foo", pwd = "passwd"),
#' opts = list(verbose = TRUE)
#' )
Expand All @@ -70,15 +70,15 @@
#' # failure behavior
#' ## e.g. when a URL doesn't exist, a timeout, etc.
#' urls <- c("http://stuffthings.gvb", "https://foo.com",
#' "https://httpbin.org/get")
#' "https://hb.opencpu.org/get")
#' conn <- Async$new(urls = urls)
#' res <- conn$get()
#' res[[1]]$parse("UTF-8") # a failure
#' res[[2]]$parse("UTF-8") # a failure
#' res[[3]]$parse("UTF-8") # a success
#'
#' # retry
#' urls = c("https://httpbin.org/status/404", "https://httpbin.org/status/429")
#' urls = c("https://hb.opencpu.org/status/404", "https://hb.opencpu.org/status/429")
#' conn <- Async$new(urls = urls)
#' res <- conn$retry(verb="get")
#' }
Expand Down Expand Up @@ -151,9 +151,9 @@ Async <- R6::R6Class(
#' execute the `GET` http verb for the `urls`
#' @examples \dontrun{
#' (cc <- Async$new(urls = c(
#' 'https://httpbin.org/',
#' 'https://httpbin.org/get?a=5',
#' 'https://httpbin.org/get?foo=bar'
#' 'https://hb.opencpu.org/',
#' 'https://hb.opencpu.org/get?a=5',
#' 'https://hb.opencpu.org/get?foo=bar'
#' )))
#' (res <- cc$get())
#' }
Expand Down Expand Up @@ -222,9 +222,9 @@ Async <- R6::R6Class(
#' @examples \dontrun{
#' cc <- Async$new(
#' urls = c(
#' 'https://httpbin.org/',
#' 'https://httpbin.org/get?a=5',
#' 'https://httpbin.org/get?foo=bar'
#' 'https://hb.opencpu.org/',
#' 'https://hb.opencpu.org/get?a=5',
#' 'https://hb.opencpu.org/get?foo=bar'
#' )
#' )
#' (res <- cc$verb('get'))
Expand Down
36 changes: 18 additions & 18 deletions R/asyncvaried.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
#' @examples \dontrun{
#' # pass in requests via ...
#' req1 <- HttpRequest$new(
#' url = "https://httpbin.org/get",
#' url = "https://hb.opencpu.org/get",
#' opts = list(verbose = TRUE),
#' headers = list(foo = "bar")
#' )$get()
#' req2 <- HttpRequest$new(url = "https://httpbin.org/post")$post()
#' req2 <- HttpRequest$new(url = "https://hb.opencpu.org/post")$post()
#'
#' # Create an AsyncVaried object
#' out <- AsyncVaried$new(req1, req2)
Expand Down Expand Up @@ -50,27 +50,27 @@
#' # use $verb() method to select http verb
#' method <- "post"
#' req1 <- HttpRequest$new(
#' url = "https://httpbin.org/post",
#' url = "https://hb.opencpu.org/post",
#' opts = list(verbose = TRUE),
#' headers = list(foo = "bar")
#' )$verb(method)
#' req2 <- HttpRequest$new(url = "https://httpbin.org/post")$verb(method)
#' req2 <- HttpRequest$new(url = "https://hb.opencpu.org/post")$verb(method)
#' out <- AsyncVaried$new(req1, req2)
#' out
#' out$request()
#' out$responses()
#'
#' # pass in requests in a list via .list param
#' reqlist <- list(
#' HttpRequest$new(url = "https://httpbin.org/get")$get(),
#' HttpRequest$new(url = "https://httpbin.org/post")$post(),
#' HttpRequest$new(url = "https://httpbin.org/put")$put(),
#' HttpRequest$new(url = "https://httpbin.org/delete")$delete(),
#' HttpRequest$new(url = "https://httpbin.org/get?g=5")$get(),
#' HttpRequest$new(url = "https://hb.opencpu.org/get")$get(),
#' HttpRequest$new(url = "https://hb.opencpu.org/post")$post(),
#' HttpRequest$new(url = "https://hb.opencpu.org/put")$put(),
#' HttpRequest$new(url = "https://hb.opencpu.org/delete")$delete(),
#' HttpRequest$new(url = "https://hb.opencpu.org/get?g=5")$get(),
#' HttpRequest$new(
#' url = "https://httpbin.org/post")$post(body = list(y = 9)),
#' url = "https://hb.opencpu.org/post")$post(body = list(y = 9)),
#' HttpRequest$new(
#' url = "https://httpbin.org/get")$get(query = list(hello = "world"))
#' url = "https://hb.opencpu.org/get")$get(query = list(hello = "world"))
#' )
#'
#' out <- AsyncVaried$new(.list = reqlist)
Expand All @@ -82,7 +82,7 @@
#' out$parse()
#'
#' # using auth with async
#' url <- "https://httpbin.org/basic-auth/user/passwd"
#' url <- "https://hb.opencpu.org/basic-auth/user/passwd"
#' auth <- auth(user = "user", pwd = "passwd")
#' reqlist <- list(
#' HttpRequest$new(url = url, auth = auth)$get(),
Expand All @@ -98,8 +98,8 @@
#' ## e.g. when a URL doesn't exist, a timeout, etc.
#' reqlist <- list(
#' HttpRequest$new(url = "http://stuffthings.gvb")$get(),
#' HttpRequest$new(url = "https://httpbin.org")$head(),
#' HttpRequest$new(url = "https://httpbin.org",
#' HttpRequest$new(url = "https://hb.opencpu.org")$head(),
#' HttpRequest$new(url = "https://hb.opencpu.org",
#' opts = list(timeout_ms = 10))$head()
#' )
#' (tmp <- AsyncVaried$new(.list = reqlist))
Expand All @@ -121,10 +121,10 @@
#'
#' # retry
#' reqlist <- list(
#' HttpRequest$new(url = "https://httpbin.org/get")$get(),
#' HttpRequest$new(url = "https://httpbin.org/post")$post(),
#' HttpRequest$new(url = "https://httpbin.org/status/404")$retry("get"),
#' HttpRequest$new(url = "https://httpbin.org/status/429")$retry("get",
#' HttpRequest$new(url = "https://hb.opencpu.org/get")$get(),
#' HttpRequest$new(url = "https://hb.opencpu.org/post")$post(),
#' HttpRequest$new(url = "https://hb.opencpu.org/status/404")$retry("get"),
#' HttpRequest$new(url = "https://hb.opencpu.org/status/429")$retry("get",
#' retry_only_on = c(403, 429), times = 2)
#' )
#' tmp <- AsyncVaried$new(.list = reqlist)
Expand Down
4 changes: 2 additions & 2 deletions R/auth.R
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#' \dontrun{
#' # with HttpClient
#' (res <- HttpClient$new(
#' url = "https://httpbin.org/basic-auth/user/passwd",
#' url = "https://hb.opencpu.org/basic-auth/user/passwd",
#' auth = auth(user = "user", pwd = "passwd")
#' ))
#' res$auth
Expand All @@ -36,7 +36,7 @@
#'
#' # with HttpRequest
#' (res <- HttpRequest$new(
#' url = "https://httpbin.org/basic-auth/user/passwd",
#' url = "https://hb.opencpu.org/basic-auth/user/passwd",
#' auth = auth(user = "user", pwd = "passwd")
#' ))
#' res$auth
Expand Down
12 changes: 6 additions & 6 deletions R/client.R
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
#'
#' @examples \dontrun{
#' # set your own handle
#' (h <- handle("https://httpbin.org"))
#' (h <- handle("https://hb.opencpu.org"))
#' (x <- HttpClient$new(handle = h))
#' x$handle
#' x$url
Expand All @@ -61,7 +61,7 @@
#'
#' # if you just pass a url, we create a handle for you
#' # this is how most people will use HttpClient
#' (x <- HttpClient$new(url = "https://httpbin.org"))
#' (x <- HttpClient$new(url = "https://hb.opencpu.org"))
#' x$url
#' x$handle # is empty, it gets created when a HTTP verb is called
#' (r1 <- x$get('get'))
Expand Down Expand Up @@ -98,7 +98,7 @@
#'
#' # query params are URL encoded for you, so DO NOT do it yourself
#' ## if you url encode yourself, it gets double encoded, and that's bad
#' (x <- HttpClient$new(url = "https://httpbin.org"))
#' (x <- HttpClient$new(url = "https://hb.opencpu.org"))
#' res <- x$get("get", query = list(a = 'hello world'))
#'
#' # access intermediate headers in response_headers_all
Expand Down Expand Up @@ -344,7 +344,7 @@ HttpClient <- R6::R6Class(
#' @param verb an HTTP verb supported on this class: "get",
#' "post", "put", "patch", "delete", "head". Also supports retry.
#' @examples \dontrun{
#' (x <- HttpClient$new(url = "https://httpbin.org"))
#' (x <- HttpClient$new(url = "https://hb.opencpu.org"))
#' x$verb('get')
#' x$verb('GET')
#' x$verb('GET', query = list(foo = "bar"))
Expand Down Expand Up @@ -386,7 +386,7 @@ HttpClient <- R6::R6Class(
#' Note that the time spent in the function effectively adds to the wait time,
#' so it should be kept simple.
#' @examples \dontrun{
#' x <- HttpClient$new(url = "https://httpbin.org")
#' x <- HttpClient$new(url = "https://hb.opencpu.org")
#'
#' # retry, by default at most 3 times
#' (res_get <- x$retry("GET", path = "status/400"))
Expand Down Expand Up @@ -454,7 +454,7 @@ HttpClient <- R6::R6Class(
#' parameters; body and any curl options don't change the URL
#' @return URL (character)
#' @examples
#' x <- HttpClient$new(url = "https://httpbin.org")
#' x <- HttpClient$new(url = "https://hb.opencpu.org")
#' x$url_fetch()
#' x$url_fetch('get')
#' x$url_fetch('post')
Expand Down
2 changes: 1 addition & 1 deletion R/content-types.R
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
#'
#' @seealso [HttpResponse]
#' @examples \dontrun{
#' (x <- HttpClient$new(url = "https://httpbin.org"))
#' (x <- HttpClient$new(url = "https://hb.opencpu.org"))
#' (res <- x$get())
#'
#' ## see the content type
Expand Down
4 changes: 2 additions & 2 deletions R/cookies.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#' @name cookies
#' @examples \dontrun{
#' x <- HttpClient$new(
#' url = "https://httpbin.org",
#' url = "https://hb.opencpu.org",
#' opts = list(
#' cookie = "c=1;f=5",
#' verbose = TRUE
Expand All @@ -15,7 +15,7 @@
#' (res <- x$get("cookies"))
#' jsonlite::fromJSON(res$parse("UTF-8"))
#'
#' (x <- HttpClient$new(url = "https://httpbin.org"))
#' (x <- HttpClient$new(url = "https://hb.opencpu.org"))
#' res <- x$get("cookies/set", query = list(foo = 123, bar = "ftw"))
#' jsonlite::fromJSON(res$parse("UTF-8"))
#' curl::handle_cookies(handle = res$handle)
Expand Down
2 changes: 1 addition & 1 deletion R/curl-options.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#' @aliases user-agent verbose timeout
#'
#' @examples \dontrun{
#' url <- "https://httpbin.org"
#' url <- "https://hb.opencpu.org"
#'
#' # set curl options on client initialization
#' (res <- HttpClient$new(url = url, opts = list(verbose = TRUE)))
Expand Down
4 changes: 2 additions & 2 deletions R/handle.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
#' @param url (character) A url. required.
#' @param ... options passed on to [curl::new_handle()]
#' @examples
#' handle("https://httpbin.org")
#' handle("https://hb.opencpu.org")
#'
#' # handles - pass in your own handle
#' \dontrun{
#' h <- handle("https://httpbin.org")
#' h <- handle("https://hb.opencpu.org")
#' (res <- HttpClient$new(handle = h))
#' out <- res$get("get")
#' }
Expand Down
8 changes: 4 additions & 4 deletions R/hooks.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#' fun_req <- function(request) {
#' cat(paste0("Requesting: ", request$url$url), sep = "\n")
#' }
#' (x <- HttpClient$new(url = "https://httpbin.org",
#' (x <- HttpClient$new(url = "https://hb.opencpu.org",
#' hooks = list(request = fun_req)))
#' x$hooks
#' x$hooks$request
Expand All @@ -33,7 +33,7 @@
#' cat("Capturing Request", sep = "\n")
#' captured_req <<- request
#' }
#' (x <- HttpClient$new(url = "https://httpbin.org",
#' (x <- HttpClient$new(url = "https://hb.opencpu.org",
#' hooks = list(request = fun_req2)))
#' x$hooks
#' x$hooks$request
Expand All @@ -46,14 +46,14 @@
#' fun_resp <- function(response) {
#' cat(paste0("status_code: ", response$status_code), sep = "\n")
#' }
#' (x <- HttpClient$new(url = "https://httpbin.org",
#' (x <- HttpClient$new(url = "https://hb.opencpu.org",
#' hooks = list(response = fun_resp)))
#' x$url
#' x$hooks
#' r1 <- x$get('get')
#'
#' # both
#' (x <- HttpClient$new(url = "https://httpbin.org",
#' (x <- HttpClient$new(url = "https://hb.opencpu.org",
#' hooks = list(request = fun_req, response = fun_resp)))
#' x$get("get")
#' }
Expand Down
6 changes: 3 additions & 3 deletions R/http-headers.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
#'
#' @name http-headers
#' @examples \dontrun{
#' (x <- HttpClient$new(url = "https://httpbin.org"))
#' (x <- HttpClient$new(url = "https://hb.opencpu.org"))
#'
#' # set headers
#' (res <- HttpClient$new(
#' url = "https://httpbin.org",
#' url = "https://hb.opencpu.org",
#' opts = list(
#' verbose = TRUE
#' ),
Expand All @@ -25,7 +25,7 @@
#'
#' ## setting content-type via headers
#' (res <- HttpClient$new(
#' url = "https://httpbin.org",
#' url = "https://hb.opencpu.org",
#' opts = list(
#' verbose = TRUE
#' ),
Expand Down
Loading

0 comments on commit b0de342

Please sign in to comment.