| 1 |
\name{basicHeaderGatherer} |
| 2 |
\alias{basicHeaderGatherer} |
| 3 |
\alias{parseHTTPHeader} |
| 4 |
\title{Functions for processing the response header of a libcurl request} |
| 5 |
\description{ |
| 6 |
These two functions are used to collect the contents of the header of |
| 7 |
an HTTP response via the \code{headerfunction} option of a curl handle |
| 8 |
and then processing that text into both the name: value pairs |
| 9 |
and also the initial line of the response that provides the |
| 10 |
status of the request. |
| 11 |
\code{basicHeaderGatherer} is a simple special case of |
| 12 |
\code{\link{basicTextGatherer}} with the built-in post-processing |
| 13 |
step done by \code{parseHTTPHeader}. |
| 14 |
} |
| 15 |
\usage{ |
| 16 |
basicHeaderGatherer(txt = character(), max = NA) |
| 17 |
parseHTTPHeader(lines, multi = TRUE) |
| 18 |
} |
| 19 |
\arguments{ |
| 20 |
\item{txt}{any initial text that we want included with the header. |
| 21 |
This is passed to \code{\link{basicTextGatherer}}. Generally it |
| 22 |
should not be specified unless there is a good reason.} |
| 23 |
\item{max}{This is passed directly to |
| 24 |
\code{\link{basicTextGatherer}}} |
| 25 |
\item{lines}{ the text as a character vector from the response header |
| 26 |
that |
| 27 |
\code{parseHTTPHeader} will convert to a status and name-value |
| 28 |
pairs.} |
| 29 |
\item{multi}{a logical value controlling whether we check for |
| 30 |
multiple HTTP headers in the lines of text. This is caused |
| 31 |
by a Continue being concatenated with the actual response. |
| 32 |
When this is \code{TRUE}, we look for the lines |
| 33 |
that start an HTTP header, e.g. \code{HTTP 200 ...}, |
| 34 |
and we use the content from the last of these. |
| 35 |
} |
| 36 |
} |
| 37 |
\value{ |
| 38 |
The return value is the same as \code{\link{basicTextGatherer}}, |
| 39 |
i.e. a list with |
| 40 |
\code{update}, \code{value} and \code{reset} function elements. |
| 41 |
The \code{value} element will invoke \code{parseHTTPHeader} |
| 42 |
on the contents read during the processing of the libcurl request |
| 43 |
and return that value. |
| 44 |
} |
| 45 |
\references{Curl homepage \url{https://curl.se/}} |
| 46 |
\author{Duncan Temple Lang} |
| 47 |
|
| 48 |
\seealso{ |
| 49 |
\code{\link{basicTextGatherer}} |
| 50 |
\code{\link{curlPerform}} |
| 51 |
\code{\link{curlSetOpt}} |
| 52 |
} |
| 53 |
\examples{ |
| 54 |
tryCatch(withAutoprint({ |
| 55 |
h = basicHeaderGatherer() |
| 56 |
getURI("https://r-project.org", |
| 57 |
headerfunction = h$update) |
| 58 |
names(h$value()) |
| 59 |
h$value() |
| 60 |
}), GenericCurlError = identity) |
| 61 |
} |
| 62 |
\keyword{IO} |
| 63 |
\concept{network client} |
| 64 |
|