I would like to get response headers from GET or POST.
My example is:
library(httr)
library(RCurl)
url<-'http://www.omegahat.org/RCurl/philosophy.html'
doc<-GET(url)
names(doc)
[1] "url" "handle" "status_code" "headers" "cookies" "content" "times" "config"
but there is no response headers, only request headers.
Result shoud be something like this:
Connection:Keep-Alive
Date:Mon, 11 Feb 2013 20:21:56 GMT
ETag:"126a001-e33d-4c12cf2702440"
Keep-Alive:timeout=15, max=100
Server:Apache/2.2.14 (Ubuntu)
Vary:Accept-Encoding
Can I do this with R and httr/RCurl packages or R is not enough for this kind of problem?
Edit: I would like to get all response headers. I am mainly interested in Location response which is not in this example.
Edit2: I forgot to tell the system which I work on - it is Windows 7
My session.info
> sessionInfo()
R version 2.15.2 (2012-10-26)
Platform: x86_64-w64-mingw32/x64 (64-bit)
locale:
[1] LC_COLLATE=Polish_Poland.1250 LC_CTYPE=Polish_Poland.1250 LC_MONETARY=Polish_Poland.1250
[4] LC_NUMERIC=C LC_TIME=Polish_Poland.1250
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] rjson_0.2.12 RCurl_1.95-3 bitops_1.0-5 httr_0.2 XML_3.95-0.1
loaded via a namespace (and not attached):
[1] digest_0.6.2 stringr_0.6.2 tools_2.15.2
curl -I http://www.google.com
curl -v http://google.com/
You can do it this way :
Which will give you a named vector :