I am trying to have WinHttp make a “CONNECT” calls (as opposed to a “GET” or “POST”) that looks as follows:
CONNECT www.etrade.com:443 HTTP/1.0
Host: www.etrade.com
However, winhttp always enforces a path after the “CONNECT” verb as follows (at the front of the location):
CONNECT /www.etrade.com:443 HTTP/1.0
Host: www.etrade.com
Any workaround? or am I doing something wrong? This is in C# .net 3.5 framework, Winhttp 5.1
CONNECT isn't a HTTP verb, it's the start of a HTTPS request ({the SSL connect portion). With WinHTTP, you just use the WINHTTP_FLAG_SECURE
on OpenRequest. Something like:
hConnect = WinHttpConnect(
hSession,
"www.etrade.com",
443,
0
);
hRequest = WinHttpOpenRequest(
hConnect,
"GET",
"/",
"HTTP/1.0",
WINHTTP_NO_REFERER,
WINHTTP_DEFAULT_ACCEPT_TYPES,
WINHTTP_FLAG_SECURE
);
That gets you a CONNECT (for the SSL connection), and then a GET /
(for the HTTP portion).