Click here to Skip to main content
13,863,289 members
Rate this:
 
Please Sign up or sign in to vote.
See more:
OS: Windows XP SP3. Application should download the picture from the website via https protocol. As a result, WinHttpSendRequest returns an error -2146893018. Here is the code snippet:

What I have tried:

hRequest = WinHttpOpenRequest(hConnect, L"GET", Path, Protocol, 0, 0, WINHTTP_FLAG_SECURE);

    if(hRequest){
        bResults = WinHttpSendRequest(hRequest, WINHTTP_NO_ADDITIONAL_HEADERS, 0,
                                      WINHTTP_NO_REQUEST_DATA, 0, 0, 0);
    ...
    }

This problem is only on WinXP. On Windows 7 - everything works fine.

But if try to download another image from another website via http protocol (replacing WINHTTP_FLAG_SECURE with 0), then everything works fine. What's wrong?
Posted
Updated 11-Feb-19 7:59am
Comments
Richard MacCutchan 11-Feb-19 6:38am
   
The error code is actually 80090326: see error 80090326 - Google Search[^] for potential causes.
Igor-84 11-Feb-19 6:49am
   
Described as: "The message received was unexpected or badly formatted". What should I fix in my code?
Richard MacCutchan 11-Feb-19 6:56am
   
You need to look at the data being passed between your client and server. No one here can guess what is wrong with it.
KarstenK 11-Feb-19 7:00am
   
I strongly recommend NOT using the retired Windows XP on the internet. It has critical issues and you may end infected by some malware like an encrypt disk.
Igor-84 11-Feb-19 7:05am
   
And how to do it?
P.S. picture downloads from google images
Richard MacCutchan 11-Feb-19 7:25am
   
Use your debugger, or add some logging code. Debugging your applications is an essential part of being a developer. It is a skill you need to work on.
Igor-84 11-Feb-19 9:09am
   
Using newest Windows versions is not solution in my case. I use Windows 7 and this code work well here. And I need to work this code on Windows XP too.
Igor-84 11-Feb-19 9:13am
   
Hmmm... All that debugger says is that WinHttpOpenRequest() works OK, and WinHttpSendRequest() returns GetLastError = -2146893018. Maybe WinHTTP has some restriction on Windows XP? But I didn't find any information about it in internet.
Richard MacCutchan 11-Feb-19 10:13am
   
OK, so you need to check the contents of the message being sent in your WinHttpSendRequest, since that is what is causing the error. It may well be that you are using code or library versions that are not compatible with Windows XP.
Rick York 11-Feb-19 11:05am
   
Mr. MacCutchan gave an important tip that you might not have realized. Nearly all of Microsoft's documentation deals with error codes in hexadecimal format so you should do the same for easier referencing. I always use a format string of "%08X" when displaying windows error codes and I recommend that you do the same.
Igor-84 11-Feb-19 11:10am
   
I don't know where I can check the contents of the message. In Windows XP I set up Visual Studio 2008, created a new project and compiled my downloader code. And while debugging WinHttpSendRequest() returns the same result "The message received was unexpected or badly formatted".
Richard MacCutchan 11-Feb-19 11:48am
   
There is really no point in posting exactly the same details in every message. You already know what the error code is and what it means. So use your debugger to inspect the values that you are trying to send to the server. As I said earlier, no one here can guess what is happening.
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

The "problem" is that you are "expecting" both XP and Windows 7 to "act the same".

The fact that Windows 7 still gets updates and not XP probably means there are "differences".

The fact that you found a method that works but still wonder "why" the other method doesn't shouldn't be a concern at this point.
   
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

It is looks like I found explanation why WinHttpSendRequest() returned an error -2146893018 or 2148074278 on Windows XP SP3.
The problem is the version of the TLS encryption protocol that WinXP system uses is TLS 1.0.
Some websites that works on https don't support TLS version 1.0. Highly likely, such websites reject connection if client tries to communicate with them.
Therefore, Windows 7 uses TLS version 1.1 and 1.2. Thus and so such websites work with clients correctly.
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Cookies | Terms of Service
Web04 | 2.8.190214.1 | Last Updated 12 Feb 2019
Copyright © CodeProject, 1999-2019
All Rights Reserved.
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100