Debian Codegraph @

man/curl_echo.Rd

raw
1 % Generated by roxygen2: do not edit by hand
2 % Please edit documentation in R/echo.R
3 \name{curl_echo}
4 \alias{curl_echo}
5 \alias{find_port}
6 \title{Echo Service}
7 \usage{
8 curl_echo(handle, port = find_port(), progress = interactive(), file = NULL)
9
10 find_port(range = NULL)
11 }
12 \arguments{
13 \item{handle}{a curl handle object}
14
15 \item{port}{the port number on which to run httpuv server}
16
17 \item{progress}{show progress meter during http transfer}
18
19 \item{file}{path or connection to write body. Default returns body as raw vector.}
20
21 \item{range}{optional integer vector of ports to consider}
22 }
23 \description{
24 This function is only for testing purposes. It starts a local httpuv server to
25 echo the request body and content type in the response.
26 }
27 \examples{
28 if(require('httpuv')){
29 h <- new_handle(url = 'https://hb.cran.dev/post')
30 handle_setform(h, foo = "blabla", bar = charToRaw("test"),
31 myfile = form_file(system.file("DESCRIPTION"), "text/description"))
32
33 # Echo the POST request data
34 formdata <- curl_echo(h)
35
36 # Show the multipart body
37 cat(rawToChar(formdata$body))
38
39 # Parse multipart
40 webutils::parse_http(formdata$body, formdata$content_type)
41 }
42 }