1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
|
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/echo.R
\name{curl_echo}
\alias{curl_echo}
\alias{find_port}
\title{Echo Service}
\usage{
curl_echo(handle, port = find_port(), progress = interactive(), file = NULL)
find_port(range = NULL)
}
\arguments{
\item{handle}{a curl handle object}
\item{port}{the port number on which to run httpuv server}
\item{progress}{show progress meter during http transfer}
\item{file}{path or connection to write body. Default returns body as raw vector.}
\item{range}{optional integer vector of ports to consider}
}
\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.
}
\examples{
if(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)
}
}
|