Skip to content
Snippets Groups Projects
Commit 76507d47 authored by Robert Shearman's avatar Robert Shearman Committed by Alexandre Julliard
Browse files

wininet: Don't close the connection if the caller passes in zero for the...

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.
parent fa48cb04
No related branches found
No related tags found
No related merge requests found
......@@ -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];
......
......@@ -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;
......
......@@ -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:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment