Using RCurl's getForm
function, which is the only nice way of passing in GET-parameters, I need to alter some http headers. In getURI, you just pass httpheader = c(Whatever='whatever',...)
and it'll work. Unfortunately, that argument seems to be ignored by getForm
.
How do I set the http headers in a getForm request?
Welcome to the confusing world of RCurl! You've discovered that its syntax makes no sense, which is not your fault.
In
getForm
you pass headers as the second argument (the...
). See the usage section of? getForm
:The arguments section says:
By contrast, the other workhorse function
getURL
says:Thus, when using
getForm
, you can just pass the headers as a list, but when usinggetURL
, you need to specify them in ahttpheader
argument.My general advice is therefore to always use
curlPerform
instead of any of the wrapper functions (likegetForm
orgetURL
), because then you'll always be using a consistent syntax.