Discussion:
InternetWriteFile Returns Success But BytesWritten = 0
(too old to reply)
Bruce H
2004-12-14 20:05:17 UTC
Permalink
Hello,

I am trying to use HttpSendRequestEx and InternetWriteFile to upload files
to an IIS server. I have this working well using FtpOpenFile and
InternetWriteFile, but I want to have an option for our users with CERN
proxies. When trying to use HTTP the InterenetWriteFile call returns 1, and
Err.LastDllError returns 0 (VB6). HttpQueryInfo for headers, response code
or text return nothing. Everything looks like it is working, but the
BytesWritten parameter of InternetWriteFile is always 0 and nothing shows up
on the server.

Thanks in advance,
Bruce Holeman
***@all_spam_ignored.ibssoftware.com
Stephen Sulzer
2004-12-15 11:43:02 UTC
Permalink
One thing to check: Are you also calling HttpEndRequest? If you use
HttpSendRequestEx, after you have uploaded all of the request data via
InternetWriteFile, you must then call HttpEndRequest before you can use
HttpQueryInfo to inspect any response status or headers.

You may find the following MSDN sample helpful:

SAMPLE: Using HttpSendRequestEx for Large POST Requests
http://support.microsoft.com/default.aspx?scid=kb;en-us;177188

If your code is using HttpEndRequest, then the next step would be to examine
a network trace of the HTTP request. You can do this using a network
sniffer, or with the debug version of WinInet.dll. For more information
about that, see:

884931 How to use the debug version of the Wininet.dll file for Internet
Explorer
http://support.microsoft.com/?id=884931


Stephen
Bruce H
2004-12-15 15:39:07 UTC
Permalink
Thank you for your prompt reply Stephen. Yes, I am calling HttpEndRequest
and I have looked at the packets using Ethereal and I haven't seen anything
that helped. The bytes I want to write are in the outbound packets. It's
just that they are not written. I suspect that it may be in the
configuration of the server. I want to use IIS itself to save the file so I
am using the "PUT" command instead of "POST" as in the example you
referenced. The only reason I suspect the server configuration is that
everything appears to be working other than the bytes being saved in a file
at the server side. The network admin and I have looked at the settings
several times and have verified that WebDAV is running and the virtual
folder has write permissions, but IIS configuration is new to us and we're
learning as we go on this.

Bruce Holeman
Post by Stephen Sulzer
One thing to check: Are you also calling HttpEndRequest? If you use
HttpSendRequestEx, after you have uploaded all of the request data via
InternetWriteFile, you must then call HttpEndRequest before you can use
HttpQueryInfo to inspect any response status or headers.
SAMPLE: Using HttpSendRequestEx for Large POST Requests
http://support.microsoft.com/default.aspx?scid=kb;en-us;177188
If your code is using HttpEndRequest, then the next step would be to examine
a network trace of the HTTP request. You can do this using a network
sniffer, or with the debug version of WinInet.dll. For more information
884931 How to use the debug version of the Wininet.dll file for Internet
Explorer
http://support.microsoft.com/?id=884931
Stephen
Paul Baker [MVP, Windows - SDK]
2004-12-15 23:20:28 UTC
Permalink
Maybe you could try using a test IIS web server on your own machine?

Paul
Post by Bruce H
Thank you for your prompt reply Stephen. Yes, I am calling HttpEndRequest
and I have looked at the packets using Ethereal and I haven't seen anything
that helped. The bytes I want to write are in the outbound packets. It's
just that they are not written. I suspect that it may be in the
configuration of the server. I want to use IIS itself to save the file so I
am using the "PUT" command instead of "POST" as in the example you
referenced. The only reason I suspect the server configuration is that
everything appears to be working other than the bytes being saved in a file
at the server side. The network admin and I have looked at the settings
several times and have verified that WebDAV is running and the virtual
folder has write permissions, but IIS configuration is new to us and we're
learning as we go on this.
Bruce Holeman
Post by Stephen Sulzer
One thing to check: Are you also calling HttpEndRequest? If you use
HttpSendRequestEx, after you have uploaded all of the request data via
InternetWriteFile, you must then call HttpEndRequest before you can use
HttpQueryInfo to inspect any response status or headers.
SAMPLE: Using HttpSendRequestEx for Large POST Requests
http://support.microsoft.com/default.aspx?scid=kb;en-us;177188
If your code is using HttpEndRequest, then the next step would be to examine
a network trace of the HTTP request. You can do this using a network
sniffer, or with the debug version of WinInet.dll. For more information
884931 How to use the debug version of the Wininet.dll file for Internet
Explorer
http://support.microsoft.com/?id=884931
Stephen
e***@gmail.com
2004-12-22 17:53:14 UTC
Permalink
I have the same problem against an Apache web server. Did not find out
a solution to this

ludo

Loading...