Module: wine Branch: master Commit: 01e7d128483cf4bec401dee3fc8a479109d7a072 URL: http://source.winehq.org/git/wine.git/?a=commit;h=01e7d128483cf4bec401dee3fc...
Author: Hans Leidekker hans@codeweavers.com Date: Mon Sep 8 22:02:01 2008 +0200
winhttp: WinHttpQueryDataAvailable should do a blocking read if more data is expected.
Spotted by Henri Verbeet.
---
dlls/winhttp/net.c | 6 +----- dlls/winhttp/request.c | 21 ++++++++++++++++++++- 2 files changed, 21 insertions(+), 6 deletions(-)
diff --git a/dlls/winhttp/net.c b/dlls/winhttp/net.c index 1abfbdd..450366b 100644 --- a/dlls/winhttp/net.c +++ b/dlls/winhttp/net.c @@ -464,11 +464,7 @@ BOOL netconn_query_data_available( netconn_t *conn, DWORD *available ) return TRUE; } #ifdef FIONREAD - if (!(ret = ioctl( conn->socket, FIONREAD, &unread ))) - { - TRACE("%d bytes of queued, but unread data\n", unread); - *available += unread; - } + if (!(ret = ioctl( conn->socket, FIONREAD, &unread ))) *available = unread; #endif return TRUE; } diff --git a/dlls/winhttp/request.c b/dlls/winhttp/request.c index d1fc005..46c6d6d 100644 --- a/dlls/winhttp/request.c +++ b/dlls/winhttp/request.c @@ -1238,7 +1238,26 @@ static BOOL query_data( request_t *request, LPDWORD available, BOOL async ) BOOL ret; DWORD num_bytes;
- ret = netconn_query_data_available( &request->netconn, &num_bytes ); + if ((ret = netconn_query_data_available( &request->netconn, &num_bytes ))) + { + if (request->content_read < request->content_length) + { + if (!num_bytes) + { + char buffer[4096]; + size_t to_read = min( sizeof(buffer), request->content_length - request->content_read ); + + ret = netconn_recv( &request->netconn, buffer, to_read, MSG_PEEK, (int *)&num_bytes ); + if (ret && !num_bytes) WARN("expected more data to be available\n"); + } + } + else if (num_bytes) + { + WARN("extra data available %u\n", num_bytes); + ret = FALSE; + } + } + TRACE("%u bytes available\n", num_bytes);
if (async) {