wininet: Don't close the connection if the caller passes in zero for the number of bytes to be read.

Only close the connection when the bytes read equals the content length.

Fixup HTTP_DrainContent, which relied on the previous incorrect 
behaviour to instead close connections with no content length manually.
This commit is contained in:
Rob Shearman 2007-05-28 11:13:36 +01:00 committed by Alexandre Julliard
parent fa48cb042c
commit 76507d475b
3 changed files with 8 additions and 1 deletions

View File

@ -738,6 +738,12 @@ BOOL WINAPI HttpAddRequestHeadersA(HINTERNET hHttpRequest,
static void HTTP_DrainContent(LPWININETHTTPREQW lpwhr)
{
DWORD bytes_read;
if (!NETCON_connected(&lpwhr->netConnection)) return;
if (lpwhr->dwContentLength == -1)
NETCON_close(&lpwhr->netConnection);
do
{
char buffer[2048];

View File

@ -1724,7 +1724,7 @@ BOOL INTERNET_ReadFile(LPWININETHANDLEHEADER lpwh, LPVOID lpBuffer,
{
lpwhr->dwContentRead += bytes_read;
*pdwNumOfBytesRead = bytes_read;
if (!bytes_read)
if (!bytes_read && (lpwhr->dwContentRead == lpwhr->dwContentLength))
retval = HTTP_FinishedReading(lpwhr);
else
retval = TRUE;

View File

@ -444,6 +444,7 @@ static void InternetReadFileExA_test(int flags)
length += inetbuffers.dwBufferLength;
}
ok(length > 0, "failed to read any of the document\n");
trace("Finished. Read %d bytes\n", length);
abort: