Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

InternetQueryDataAvailable/InternetReadFile() problems.

5 views
Skip to first unread message

SomeTimesATechie

unread,
Oct 4, 2001, 11:33:41 PM10/4/01
to
All,

My problem. I have a custom Async WinINet DLL. It establishes a secure SSL
connection to our webserver, using valid server and client certificates.
Everything is fine until the server response (response content) is greater
then 843 bytes. If the response content is >843 bytes
InternetQueryDataAvailable() only shows 843 bytes and I can only
InternetReadFile() the 843 bytes. Yet my content-length shows an amount
greater than that. All subsequent InternetQueryDataAvailable() calls return
0. (I've let it loop for over 5 minutes with no luck) I have verified that
the Java Servlet on the server is most likely not setting an incorrect
content length- but the HTTP proxy I try to use to figure out the response
size, hangs (most likely can't deal with custom headers or something).

I'm down to the wire on this one- I need to get this module up and running
and obviously, not being able to read all the response data is a major
snag. I've thought about trying InternetReadFileEx() and might get a chance
to try that tomorrow- can anybody help!? System is WinNT 4.0 Workstation
running IE 5.5 with a crypt32.dll upgrade to fix a documented hang bug.
Last upgrade was to IE; 5.5 and the crypt32.dll appears to be the same that
I downloaded for the hang bug.

If you need more info or any particular WinInet() arguments I'll be happy
to provide them as quickly as possible. I do have a log file with a good
session followed by a bad session, however a previous post of this message
with log file attached seems to have been filtered out. I'd be more than
happy to email the log to anybody who thinks they can help.

Please reply to the newgroup only.


Regards,
STAT.

Abhuday Aggarwal [MS]

unread,
Oct 5, 2001, 12:16:43 PM10/5/01
to
Here is some information that should be of help.

If you call the wininet function InternetQueryDataAvailable it will not
necessarily return the entire size of the data being downloaded

<><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
<>

The problem is that InternetQueryDataAvailable simply returns the number of
bytes immediately available. There may be a lot more data being
transfered,
but it hasn't made it to the client machine's local buffers yet. There is
a
good chance that this is not the entire size of the download. Therefore if
you were using InternetQueryDataAvailable to tell you the size of the
buffer
to allocate to hold the entire response, then you will not get all your
data.

For HTTP transfers you can usually get the size by getting the
Content-Length
header. For FTP transfers you can usually use the FtpGetFileSize()
function
to get the size. See
Q172712(http://support.microsoft.com/support/kb/articles/q172/7/12.asp)
for more information on problems trying to get an FTP file's size on
certain FTP servers.

I hope this helps.

-Abhuday

This posting is provided "AS IS" with no warranties, and confers no rights.
You assume all risk for your use. © 2001 Microsoft Corporation. All rights
reserved.

SomeTimesATechie

unread,
Oct 5, 2001, 6:08:22 PM10/5/01
to
Abhuday,

As in my original post- my problem is that I am unable to
InternetReadFile() all the data because InternetQueryDataAvailable() is
returning 843 and then 0, instead of 843 than 512 then 0 like it should!

I took the AsyncDemo from microsoft- hacked it up so that it only does one
Async Request rather than two, pointed everything to our SSL server, and
added controls to specifically send the right bits of data to the
JavaServlet at the right time... unfortunately the AsyncDemo was using
InternetOpenURL() which I could not get to work with InternetErrorDlg() to
handle the client cert required error. (btw it reaturned error 57). As far
as I could tell the handle was being closed outside of AsyncDemo code (Yes I
was using KEEP_CONNECTION). So I switched the calls to HttpOpenRequest(),
etc. Got it working with SSL, client and server certs, and proceeded to
test, and what do you know- at the point in question
InternetQueryDataAvailable() returns 843 just like in mine- but the next
call returns 512 (the remained of the data) where as in my DLL the second
call returns 0!

I have a nagging feeling that I am running into a problem because my DLL
is loaded by the APP dynamically. (I do know crypt32.dll had problems with
that) My best guess at this point- is that it still does!

At this point the only way I can verify if its a defect outside of my code
is to take the 68K worth of DLL code and just include it in the app (with
some significant changes as the DLL is currently dynamically loaded at
runtime)

Regards,
STAT


SomeTimesATechie

unread,
Oct 9, 2001, 4:14:58 PM10/9/01
to
All,

I have solved the problem! In a nutshell my InternetQueryDataAvailable()
and InternetReadFile() calls were on the same thread as originally did the
HttpSendRequest() unfortunately this seems to be a context problem. I
switched to the AsyncDemo's method- where the StatusCallback function
creates a readresponse thread that buffers the response so I can retrieve
the data from the original thread and everything works fine.


STAT

0 new messages