I have followed the various knowledge based articles for large file posts
over https and for handling authentication. A summary of my technique is as
follows
InternetOpen()
InternetConnect()
HttpAddRequestHeaders()
again:
//START PROBLEM CODE
-------------------------------------------------------------
HttpOpenRequest() - with
"POST"
INTERNET_FLAG_NO_CACHE_WRITE | INTERNET_FLAG_KEEP_CONNECTION |
INTERNET_FLAG_RELOAD
HttpSendRequest() - null post to check if authenticated or problems with
SSL certificate.
if error with certificate
{
InternetErrorDlg() to check with user if ok
goto again
}
HttpQueryInfo - check for HTTP_STATUS_PROXY_AUTH_REQ || HTTP_STATUS_DENIED
if authentication needed
{
InternetErrorDlg() to check with user if ok
goto again
}
loop with InternetReadFile to read all response data
//ENDPROBLEM CODE
-------------------------------------------------------------
HttpSendRequestEx() - start large post
loop with InternetWriteFile() - send all the data
HttpEndRequest() - end large post
HttpQueryInfo() - get the status code
loop InternetReadFile() - get all the response data
The problems I am having are the following:
1. If I post using this code to test site with ssl it seems to post the data
but a 401 status code is always returned from the SECOND HttpQueryInfo after
HttpSendRequestEx. This is strange because I would have expected to get the
denied status in the initial HttpSendRequest. In this senario the dialog for
the invalid certificate gets displayed properly. If I put a break point in
the server code the initial HttpSendRequest causes the server code to run but
the HttpSendRequestEx never seems to reach the server.
2. If I post using this code to a test site without ssl and I am already
authenticated the InternetWriteFile always returns a 12030 (connection
terminated) on the second write. It seems like the initial HttpSendRequest
with no data breaks somthing for the HttpSendRequestEx and InternetWriteFile
further down.
3. If I comment out (START POBLEM CODE
to END PROBLEM CODE ) all the initial HttpSendRequest code and only use the
HttpSendRequestEx for non SSL test site the post works very well.
What am I doing that is causing the 401 in 1. and the 12030 in 2. ?
Regards
Dylan