Commit 76507d47 authored by Rob Shearman's avatar Rob Shearman Committed by Alexandre Julliard

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

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
......@@ -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:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment