Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

curl_echo

Echo Service


Description

This function is only for testing purposes. It starts a local httpuv server to echo the request body and content type in the response.

Usage

curl_echo(handle, port = 9359, progress = interactive(), file = NULL)

Arguments

handle

a curl handle object

port

the port number on which to run httpuv server

progress

show progress meter during http transfer

file

path or connection to write body. Default returns body as raw vector.

Examples

if(require('httpuv')){
h <- new_handle(url = 'https://httpbin.org/post')
handle_setform(h, foo = "blabla", bar = charToRaw("test"),
  myfile = form_file(system.file("DESCRIPTION"), "text/description"))

# Echo the POST request data
formdata <- curl_echo(h)

# Show the multipart body
cat(rawToChar(formdata$body))

# Parse multipart
webutils::parse_http(formdata$body, formdata$content_type)
}

curl

A Modern and Flexible Web Client for R

v4.3.1
MIT + file LICENSE
Authors
Jeroen Ooms [aut, cre] (<https://orcid.org/0000-0002-4035-0289>), Hadley Wickham [ctb], RStudio [cph]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.