Jacek Caban : wininet: Fixed handling of 204 No Content response.

Alexandre Julliard julliard at winehq.org
Fri May 13 11:17:51 CDT 2011


Module: wine
Branch: master
Commit: a890e3a1442f14a1c1068406f97e2d6200c1eefd
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=a890e3a1442f14a1c1068406f97e2d6200c1eefd

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Fri May 13 13:48:15 2011 +0200

wininet: Fixed handling of 204 No Content response.

---

 dlls/wininet/http.c |   37 +++++++++++++++++++++++--------------
 1 files changed, 23 insertions(+), 14 deletions(-)

diff --git a/dlls/wininet/http.c b/dlls/wininet/http.c
index 08bdd5a..19c7e76 100644
--- a/dlls/wininet/http.c
+++ b/dlls/wininet/http.c
@@ -2568,12 +2568,17 @@ static const data_stream_vtbl_t chunked_stream_vtbl = {
 };
 
 /* set the request content length based on the headers */
-static DWORD set_content_length(http_request_t *request)
+static DWORD set_content_length(http_request_t *request, DWORD status_code)
 {
     static const WCHAR szChunked[] = {'c','h','u','n','k','e','d',0};
     WCHAR encoding[20];
     DWORD size;
 
+    if(status_code == HTTP_STATUS_NO_CONTENT) {
+        request->contentLength = request->netconn_stream.content_length = 0;
+        return ERROR_SUCCESS;
+    }
+
     size = sizeof(request->contentLength);
     if (HTTP_HttpQueryInfoW(request, HTTP_QUERY_FLAG_NUMBER|HTTP_QUERY_CONTENT_LENGTH,
                             &request->contentLength, &size, NULL) != ERROR_SUCCESS)
@@ -4685,17 +4690,17 @@ static DWORD HTTP_HttpSendRequestW(http_request_t *request, LPCWSTR lpszHeaders,
             HTTP_ProcessExpires(request);
             HTTP_ProcessLastModified(request);
 
-            res = set_content_length(request);
-            if(res != ERROR_SUCCESS)
-                goto lend;
-            if(!request->contentLength)
-                http_release_netconn(request, TRUE);
-
             dwBufferSize = sizeof(dwStatusCode);
             if (HTTP_HttpQueryInfoW(request,HTTP_QUERY_FLAG_NUMBER|HTTP_QUERY_STATUS_CODE,
                                     &dwStatusCode,&dwBufferSize,NULL) != ERROR_SUCCESS)
                 dwStatusCode = 0;
 
+            res = set_content_length(request, dwStatusCode);
+            if(res != ERROR_SUCCESS)
+                goto lend;
+            if(!request->contentLength)
+                http_release_netconn(request, TRUE);
+
             if (!(request->hdr.dwFlags & INTERNET_FLAG_NO_AUTO_REDIRECT) && responseLen)
             {
                 WCHAR *new_url, szNewLocation[INTERNET_MAX_URL_LENGTH];
@@ -4795,7 +4800,7 @@ lend:
 
     if (request->session->appInfo->hdr.dwFlags & INTERNET_FLAG_ASYNC)
     {
-        if (res == ERROR_SUCCESS && request->bytesWritten == request->bytesToWrite)
+        if (res == ERROR_SUCCESS && request->contentLength && request->bytesWritten == request->bytesToWrite)
             HTTP_ReceiveRequestData(request, TRUE);
         else
         {
@@ -4835,6 +4840,7 @@ static void AsyncHttpSendRequestProc(WORKREQUEST *workRequest)
 static DWORD HTTP_HttpEndRequestW(http_request_t *request, DWORD dwFlags, DWORD_PTR dwContext)
 {
     INT responseLen;
+    DWORD dwCode, dwCodeLength;
     DWORD dwBufferSize;
     DWORD res = ERROR_SUCCESS;
 
@@ -4854,19 +4860,22 @@ static DWORD HTTP_HttpEndRequestW(http_request_t *request, DWORD dwFlags, DWORD_
     HTTP_ProcessExpires(request);
     HTTP_ProcessLastModified(request);
 
-    if ((res = set_content_length( request )) == ERROR_SUCCESS) {
+    dwCodeLength = sizeof(dwCode);
+    if (HTTP_HttpQueryInfoW(request,HTTP_QUERY_FLAG_NUMBER|HTTP_QUERY_STATUS_CODE,
+                            &dwCode,&dwCodeLength,NULL) != ERROR_SUCCESS)
+        dwCode = 0;
+
+    if ((res = set_content_length( request, dwCode )) == ERROR_SUCCESS) {
         if(!request->contentLength)
             http_release_netconn(request, TRUE);
     }
 
     if (res == ERROR_SUCCESS && !(request->hdr.dwFlags & INTERNET_FLAG_NO_AUTO_REDIRECT))
     {
-        DWORD dwCode,dwCodeLength = sizeof(DWORD);
-        if (HTTP_HttpQueryInfoW(request, HTTP_QUERY_FLAG_NUMBER|HTTP_QUERY_STATUS_CODE, &dwCode, &dwCodeLength, NULL) == ERROR_SUCCESS
-            && (dwCode == HTTP_STATUS_REDIRECT ||
+        if (dwCode == HTTP_STATUS_REDIRECT ||
                 dwCode == HTTP_STATUS_MOVED ||
                 dwCode == HTTP_STATUS_REDIRECT_METHOD ||
-                dwCode == HTTP_STATUS_REDIRECT_KEEP_VERB))
+                dwCode == HTTP_STATUS_REDIRECT_KEEP_VERB)
         {
             WCHAR *new_url, szNewLocation[INTERNET_MAX_URL_LENGTH];
             dwBufferSize=sizeof(szNewLocation);
@@ -4891,7 +4900,7 @@ static DWORD HTTP_HttpEndRequestW(http_request_t *request, DWORD dwFlags, DWORD_
         }
     }
 
-    if (res == ERROR_SUCCESS) {
+    if (res == ERROR_SUCCESS && request->contentLength) {
         HTTP_ReceiveRequestData(request, TRUE);
     }else {
         INTERNET_ASYNC_RESULT iar = {0, res};




More information about the wine-cvs mailing list