This page on msdn contains definitions of HTTP status codes presumably used in WinHTTP. Is there a way to retrieve HTTP status code from request made in WinHttp?
The only way I've found to get to response text, is to call WinHttpQueryHeaders
, which returns HTTP response like this:
HTTP/1.1 404 Not Found
Date: Wed, 28 May 2014 08:20:29 GMT
Content-Length: 0
Server: Microsoft-HTTPAPI/2.0
Do I have to parse this string by myself to get status code, or is there some way already provided by WinHttp to do this?
Just use Chrome browser. Hit F12 to get developer tools and look at the network tab. Shows you all status codes, whether page was from cache etc.
TCP port 443 is the default port used by HTTPS. If this port is blocked on any server or device from your computer to a given destination, such as www.Microsoft.com, your connection to any https site will fail and your browser will return an error message like "Secure Connection Failed" or "Page Cannot be Displayed" .
An HTTP status code is a server response to a browser's request. When you visit a website, your browser sends a request to the site's server, and the server then responds to the browser's request with a three-digit code: the HTTP status code.
Use this to read http status code (hRequest - handle of the request).
DWORD dwStatusCode = 0;
DWORD dwSize = sizeof(dwStatusCode);
WinHttpQueryHeaders(hRequest,
WINHTTP_QUERY_STATUS_CODE | WINHTTP_QUERY_FLAG_NUMBER,
WINHTTP_HEADER_NAME_BY_INDEX,
&dwStatusCode, &dwSize, WINHTTP_NO_HEADER_INDEX);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With