Echo Service
This function is only for testing purposes. It starts a local httpuv server to echo the request body and content type in the response.
curl_echo(handle, port = find_port(), progress = interactive(), file = NULL) find_port(range = NULL)
handle
: a curl handle objectport
: the port number on which to run httpuv serverprogress
: show progress meter during http transferfile
: path or connection to write body. Default returns body as raw vector.range
: optional integer vector of ports to considerif(require('httpuv')){ h <- new_handle(url = 'https://hb.cran.dev/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) }