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:
parent
fa48cb042c
commit
76507d475b
|
@ -738,6 +738,12 @@ BOOL WINAPI HttpAddRequestHeadersA(HINTERNET hHttpRequest,
|
||||||
static void HTTP_DrainContent(LPWININETHTTPREQW lpwhr)
|
static void HTTP_DrainContent(LPWININETHTTPREQW lpwhr)
|
||||||
{
|
{
|
||||||
DWORD bytes_read;
|
DWORD bytes_read;
|
||||||
|
|
||||||
|
if (!NETCON_connected(&lpwhr->netConnection)) return;
|
||||||
|
|
||||||
|
if (lpwhr->dwContentLength == -1)
|
||||||
|
NETCON_close(&lpwhr->netConnection);
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
char buffer[2048];
|
char buffer[2048];
|
||||||
|
|
|
@ -1724,7 +1724,7 @@ BOOL INTERNET_ReadFile(LPWININETHANDLEHEADER lpwh, LPVOID lpBuffer,
|
||||||
{
|
{
|
||||||
lpwhr->dwContentRead += bytes_read;
|
lpwhr->dwContentRead += bytes_read;
|
||||||
*pdwNumOfBytesRead = bytes_read;
|
*pdwNumOfBytesRead = bytes_read;
|
||||||
if (!bytes_read)
|
if (!bytes_read && (lpwhr->dwContentRead == lpwhr->dwContentLength))
|
||||||
retval = HTTP_FinishedReading(lpwhr);
|
retval = HTTP_FinishedReading(lpwhr);
|
||||||
else
|
else
|
||||||
retval = TRUE;
|
retval = TRUE;
|
||||||
|
|
|
@ -444,6 +444,7 @@ static void InternetReadFileExA_test(int flags)
|
||||||
|
|
||||||
length += inetbuffers.dwBufferLength;
|
length += inetbuffers.dwBufferLength;
|
||||||
}
|
}
|
||||||
|
ok(length > 0, "failed to read any of the document\n");
|
||||||
trace("Finished. Read %d bytes\n", length);
|
trace("Finished. Read %d bytes\n", length);
|
||||||
|
|
||||||
abort:
|
abort:
|
||||||
|
|
Loading…
Reference in New Issue