i using winhttp.lib
library send http request in c++ remote server.
on client side, http request has sent proxy ip w.x.y.z
, port 1234
.
according prototype of function winhttpopen()
(https://msdn.microsoft.com/en-us/library/windows/desktop/aa384098%28v=vs.85%29.aspx), in particular parameters dwaccesstype
, pwszproxyname
, pwszproxybypass
, looks function has told proxy.
how tell winhttpopen()
function proxy send http request (ip = w.x.y.z, port = 1234)
?
the structure winhttp_proxy_info
(https://msdn.microsoft.com/en-us/library/windows/desktop/aa383912%28v=vs.85%29.aspx) looks interesting know how use in combination winhttpopen()
.
thank you.
have tried winhttpsetoption winhttp_option_proxy flag? this:
hsession = winhttpopen(l"winhttp example/1.0", winhttp_access_type_default_proxy, winhttp_no_proxy_name, winhttp_no_proxy_bypass, 0); winhttp_proxy_info proxy = { 0 }; proxy.dwaccesstype = winhttp_access_type_named_proxy; proxy.lpszproxy = l"http://127.0.0.1:1234;http://blarg.com:4545"; if (!winhttpsetoption(hsession, winhttp_option_proxy, &proxy, sizeof(proxy))) { wprintf(l"unable set proxy.\n"); } else { hinternet hrequest = winhttpopenrequest(hconnect, l"get", null, null, winhttp_no_referer, winhttp_default_accept_types, winhttp_flag_secure); char* username = "username"; winhttpsetoption(hrequest, winhttp_option_proxy_username, username, strlen(username)); winhttpsetoption(hrequest, winhttp_option_proxy_password, password, strlen(password)); [ ... ] }
the above set session use 2 proxies... 127.0.0.1:1234, , blarg.com:4545. can change scheme using https if need. set parameters proxy username , password using winhttp_option_proxy_username, , winhttp_option_proxy_password options.
please note i've performed little no error checking. want ensure options set properly, etc.
Comments
Post a Comment