Hello Gigino,
I think the problem is the WinHttpSendRequest call:
// Send a request.This code is posting a 9 byte string, but specifies that the length is 18 bytes. It should use 9 instead, as the payload is a 9-byte ANSI string, not
if (hRequest)
bResults =WinHttpSendRequest(hRequest,
WINHTTP_NO_ADDITIONAL_HEADERS , 0,
"CS=friuli", 18, 18,
0);
a wide-character Unicode string. Sending the string as single-byte ANSI is the correct thing to do. The dwOptionalLength and dwTotalLength parameters must specify the length of the data in bytes.
WinHTTP will use the dwTotalLength parameter to generate the Content-Length header. So the server is expecting 18 bytes of data, and this would cause
the timeout error.
Also, when calling the WinHttpAddRequestHeaders function, you do not need
the \r\n characters at the end of the string, so the following is
sufficient:
bResults=WinHttpAddRequestHeaders(hRequest,
L"Content-Type: application/x-www-form-urlencoded",
-1L, WINHTTP_ADDREQ_FLAG_ADD);
Hope that helps.
Regards,
Stephen Sulzer
Microsoft Corporation
This posting is provided "AS IS" with no warranties, and confers no rights. "Gigino" <realth...@yahoo.it> wrote in message news:18b07ef0.02111...@posting.google.com...
"Stephen Sulzer \(Microsoft\)" <ssu...@online.microsoft.com> wrote inmessage news:<OQtF2hrhCHA.1392@tkmsftngp12>...
Hello,
Are you using the WinHTTP Win32 API or the WinHttpRequest COM component?
Can you post an example of your code please?
Regards,
Stephen Sulzer
Microsoft Corporation
rights.This posting is provided "AS IS" with no warranties, and confers no
"gigino" <invisibil...@yahoo.it> wrote in message news:5ffb01c28448$7cebb8d0$36ef2ecf@tkmsftngxa12...
can someone please show me a sample code of a post request
in c++ with winhttp? I've followed all instructions but i
wasn't able to make it work...
I'm using the Winhttp win32 API; the segment of code i wrote to post
data to a server is the following; i followed an example of winhttp
help in which there was only the download of an html page and i've
made the changes i thought i needed to post data, but it doesn't
work...
"CS=friuli" is the string i want to post, the page is www.myservarname.it/rs/find.asp; the error i get is 12002 (timeout),
but the problem seems to be the post... if i only read the page
without posting data, there is no problem.
Thank you for any help
Gigino
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 293 |
Nodes: | 16 (2 / 14) |
Uptime: | 219:38:47 |
Calls: | 6,622 |
Calls today: | 4 |
Files: | 12,171 |
Messages: | 5,317,867 |