Module: wine Branch: master Commit: 8df906f28e9f1bd53bc105f5b4a0d06adaca2ac2 URL: http://source.winehq.org/git/wine.git/?a=commit;h=8df906f28e9f1bd53bc105f5b4...
Author: Hans Leidekker hans@codeweavers.com Date: Tue Sep 16 12:30:51 2008 +0200
winhttp: Reset content length when all data has been read.
---
dlls/winhttp/request.c | 16 ++++++++++++++-- 1 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/dlls/winhttp/request.c b/dlls/winhttp/request.c index c149aca..b62a0e3 100644 --- a/dlls/winhttp/request.c +++ b/dlls/winhttp/request.c @@ -1226,6 +1226,13 @@ static BOOL receive_data_chunked( request_t *request, void *buffer, DWORD size, return TRUE; }
+static void finished_reading( request_t *request ) +{ + /* FIXME: close connection here if necessary */ + request->content_length = ~0UL; + request->content_read = 0; +} + static BOOL read_data( request_t *request, void *buffer, DWORD to_read, DWORD *read, BOOL async ) { static const WCHAR chunked[] = {'c','h','u','n','k','e','d',0}; @@ -1253,7 +1260,11 @@ static BOOL read_data( request_t *request, void *buffer, DWORD to_read, DWORD *r send_callback( &request->hdr, WINHTTP_CALLBACK_STATUS_REQUEST_ERROR, &result, sizeof(result) ); } } - if (ret && read) *read = num_bytes; + if (ret) + { + if (read) *read = num_bytes; + if (!num_bytes) finished_reading( request ); + } return ret; }
@@ -1263,6 +1274,7 @@ static void drain_content( request_t *request ) DWORD bytes_read; char buffer[2048];
+ if (!request->content_length) return; for (;;) { if (!read_data( request, buffer, sizeof(buffer), &bytes_read, FALSE ) || !bytes_read) return; @@ -1523,7 +1535,7 @@ static BOOL write_data( request_t *request, LPCVOID buffer, DWORD to_write, LPDW
if (async) { - if (ret) send_callback( &request->hdr, WINHTTP_CALLBACK_FLAG_WRITE_COMPLETE, &num_bytes, sizeof(DWORD) ); + if (ret) send_callback( &request->hdr, WINHTTP_CALLBACK_STATUS_WRITE_COMPLETE, &num_bytes, sizeof(DWORD) ); else { WINHTTP_ASYNC_RESULT result;