[R] RCurl - HTTP request of header ONLY

Janko Thyson janko.thyson.rstuff at googlemail.com
Fri Feb 11 15:01:06 CET 2011


Hi everyone,

I'm trying to send an HTTP request using RCurl that only requests the
response header, not the actual content. 
http://curl.haxx.se/docs/httpscripting.html says you can do this by using
the following option: curl --head http://www.something.com/

However, I can't figure out how to do this when using 'getURL()', for
example. 

Here's what I tried:
FIRST TRY
txt <- getURL("http://www.something.com/", verbose=TRUE, header=TRUE)
cat(txt)
This gives me header AND content.

SECOND TRY
headers <- basicTextGatherer()
txt     <- getURL("http://www.something.com/", header=TRUE, trace=TRUE,
headerfunction=headers$update)
cat(headers$value())
This gives me the header, but the content is also requested and sent to
'txt'.

I was looking for a RCurl option like 'head', but only found 'headerdata',
which I assumed is not what I want.

Then I also tried to understand what the individual RCurl options correspond
to in terms of the "original" libcurl options and found a respective section
in http://www.omegahat.org/RCurl/RCurlJSS.pdf (p. 10, The Request Options).
Since the name of the libcurl option is 'head', a corresponding RCurl
function should also be 'head'. Since it doesn't exist, I take it that it
hasn't been implemented (yet), correct? Is there another way to request
headers only?

Thanks a lot for any advice,
Janko

> Sys.info()
                     sysname                      release 
                   "Windows"                         "XP" 
                     version                     nodename 
"build 2600, Service Pack 3"               "ASHB-109C-02" 
                     machine                        login 
                       "x86"                     "wwa418" 
                        user 
                    "wwa418"



More information about the R-help mailing list