Browse - Programming Tips - How can I get the status code and status text from an CHttpFile?

Date: 2019mar13
Framework: MFC
Language: C/C++

Q.  How can I get the status code and status text from an CHttpFile?

A.  After SendRequest() you can use QueryInfoStatusCode() and QueryInfo()

DWORD dwStatus; CString strStatus; pFile->SendRequest(); pFile->QueryInfoStatusCode(dwStatus); // Status Number - eg 200, 404 pFile->QueryInfo(HTTP_QUERY_STATUS_TEXT, strStatus); // Status String - eg OK, Not Found pFile->QueryInfo(HTTP_QUERY_CONTENT_TYPE, strContentType); // Content-Type - eg text/html
eg dwStatus = 404, strStatus = "Not Found"