Module: wine Branch: master Commit: 76507d475b59c4efb533dd05d1ab095f834faaba URL: http://source.winehq.org/git/wine.git/?a=commit;h=76507d475b59c4efb533dd05d1...
Author: Rob Shearman rob@codeweavers.com Date: Mon May 28 11:13:36 2007 +0100
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.
---
dlls/wininet/http.c | 6 ++++++ dlls/wininet/internet.c | 2 +- dlls/wininet/tests/http.c | 1 + 3 files changed, 8 insertions(+), 1 deletions(-)
diff --git a/dlls/wininet/http.c b/dlls/wininet/http.c index c410f92..a48d7ae 100644 --- a/dlls/wininet/http.c +++ b/dlls/wininet/http.c @@ -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]; diff --git a/dlls/wininet/internet.c b/dlls/wininet/internet.c index 06611c8..4d48089 100644 --- a/dlls/wininet/internet.c +++ b/dlls/wininet/internet.c @@ -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; diff --git a/dlls/wininet/tests/http.c b/dlls/wininet/tests/http.c index 8926968..3cf5841 100644 --- a/dlls/wininet/tests/http.c +++ b/dlls/wininet/tests/http.c @@ -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: