wininet CHttpFile problem - The server returned an invalid or unrecognized response

Dear All,

I am trying to use https from C++ on w2k3 (ISAPI plugin) and have problems (works with http).
Here are key lines from my code:

      CInternetSession* internetSession = new CInternetSession ();

      CHttpConnection* connection = internetSession->GetHttpConnection (ipaddress.c_str(), INTERNET_FLAG_SECURE, INTERNET_DEFAULT_HTTPS_PORT, NULL, NULL);

      CHttpFile* f = connection->OpenRequest(CHttpConnection::HTTP_VERB_GET, objectName.c_str(), NULL, 1, NULL, NULL);

      f->SendRequest();

SendRequest throws exception:

CInternetException: The server returned an invalid or unrecognized response
Error code is: 12152

I understand this is CHttpFile problem in not being able to process standard response header?

Is this correct and is there workaround this problem?

http requests come back and the following fields are in the header:


HTTP_QUERY_CONTENT_TYPE             1: text/html; charset=utf-8
HTTP_QUERY_CONTENT_LANGUAGE       6: en-US
HTTP_QUERY_DATE                   9: Wed, 14 Dec 2011 18:16:18 GMT
HTTP_QUERY_EXPIRES            10: Thu, 01 Dec 1994 16:00:00 GMT
HTTP_QUERY_VERSION            18: HTTP/1.1
HTTP_QUERY_STATUS_CODE            19: 200
HTTP_QUERY_STATUS_TEXT            20: OK
HTTP_QUERY_RAW_HEADERS            21: HTTP/1.1 200 OK
HTTP_QUERY_RAW_HEADERS_CRLF      22: HTTP/1.1 200 OK

Server: IBM_HTTP_Server

Vary: Accept-Encoding

Cache-Control: no-cache="set-cookie, set-cookie2"

Content-Type: text/html; charset=utf-8

Date: Wed, 14 Dec 2011 18:16:18 GMT

Expires: Thu, 01 Dec 1994 16:00:00 GMT

Transfer-Encoding: chunked

Content-Language: en-US

Set-Cookie: JSESSIONID=0000NPax_1coQyMmJf6fgK-3sRi:16a14gku0; Path=/




HTTP_QUERY_SERVER            37: IBM_HTTP_Server
HTTP_QUERY_SET_COOKIE            43: JSESSIONID=0000NPax_1coQyMmJf6fgK-3sRi:16a14gku0; Path=/
HTTP_QUERY_REQUEST_METHOD      45: GET
HTTP_QUERY_CACHE_CONTROL      49: no-cache="set-cookie, set-cookie2"
HTTP_QUERY_TRANSFER_ENCODING      63: chunked
HTTP_QUERY_VARY                  65: Accept-Encoding

Any ideas what the problem and solution are?

Best wishes,
Milan
milan_novkovicAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

milan_novkovicAuthor Commented:
WinInet should't be used for this. There are all sorts of http protocol related issues, not documented.

The second one issue is fixed another one pops up. The last one that I tried was regarding redirections: https --> http and http --> https. WinInet stopped throwing exceptions here but request would never come back.

WinHTTP is straightforward to use. Version 5.1 works fine on w2k3 and that's what I switched to.

openssl works fine as well.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C++

From novice to tech pro — start learning today.