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

basicHeaderGatherer

Functions for processing the response header of a libcurl request


Description

These two functions are used to collect the contents of the header of an HTTP response via the headerfunction option of a curl handle and then processing that text into both the name: value pairs and also the initial line of the response that provides the status of the request. basicHeaderGatherer is a simple special case of basicTextGatherer with the built-in post-processing step done by parseHTTPHeader.

Usage

basicHeaderGatherer(txt = character(), max = NA)
parseHTTPHeader(lines, multi = TRUE)

Arguments

txt

any initial text that we want included with the header. This is passed to basicTextGatherer. Generally it should not be specified unless there is a good reason.

max

This is passed directly to basicTextGatherer

lines

the text as a character vector from the response header that parseHTTPHeader will convert to a status and name-value pairs.

multi

a logical value controlling whether we check for multiple HTTP headers in the lines of text. This is caused by a Continue being concatenated with the actual response. When this is TRUE, we look for the lines that start an HTTP header, e.g. HTTP 200 ..., and we use the content from the last of these.

Value

The return value is the same as basicTextGatherer, i.e. a list with update, value and reset function elements. The value element will invoke parseHTTPHeader on the contents read during the processing of the libcurl request and return that value.

Author(s)

Duncan Temple Lang

References

Curl homepage http://curl.haxx.se

See Also

Examples

if(url.exists("http://www.omegahat.net/RCurl/index.html")) withAutoprint({
     h = basicHeaderGatherer()
     getURI("http://www.omegahat.net/RCurl/index.html",
              headerfunction = h$update)
     names(h$value())
     h$value()
  })

RCurl

General Network (HTTP/FTP/...) Client Interface for R

v1.98-1.3
BSD_3_clause + file LICENSE
Authors
CRAN Team [ctb, cre] (de facto maintainer since 2013), Duncan Temple Lang [aut] (<https://orcid.org/0000-0003-0159-1546>)
Initial release

We don't support your browser anymore

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