I am trying to send an HTTP GET request in VBA which includes a cookie containing a colon character, like so:
objReq.Open "GET", "http://my.url.com?foo=bar", False
objReq.setRequestHeader "Cookie", "abcd=cookie:containing:colons"
objReq.Send
Depending on what object type I use for objReq
, however the request gets treated differently.
The following object type works:
Dim objReq As MSXML2.ServerXMLHTTP
Set objReq = New MSXML2.ServerXMLHTTP
Unfortunately, I need to use a different object type (as MSXML2.ServerXMLHTTP
can't capture sufficient detail about HTTP redirects). From what I've read, I need to use Winhttp.WinHttpRequest
, MSXML2.ServerXMLHTTP40
, or MSXML2.ServerXMLHTTP60
, but using any of those objects results in the following error when including colons in the cookie value.
I have tried replacing the colons with Chr(58)
, %3A
, and double-quoting within the string to no avail. I have also tried adding a 'Content-Type' header with various character encodings, but that doesn't seem to work either.
Anyone know how I can send a cookie value containing colons using the Winhttp.WinHttpRequest
, MSXML2.ServerXMLHTTP40
, or MSXML2.ServerXMLHTTP60
objects?
PS: Alternatively, if anyone knows how I can get the ending URL of a redirect sequence when using MSXML2.ServerXMLHTTP
, that would work as well! Winhttp.WinHttpRequest
would allow me to capture a 302 status code, and MSXML2.ServerXMLHTTP40
or MSXML2.ServerXMLHTTP60
would allow me to use GetOption(-1)
, but MSXML2.ServerXMLHTTP
doesn't support either of these methods (from what I can tell).