Jacek Caban : mshtml: Moved headers parsing to separated function.

Alexandre Julliard julliard at winehq.org
Wed Aug 4 12:27:21 CDT 2010


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

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Tue Aug  3 21:38:53 2010 +0200

mshtml: Moved headers parsing to separated function.

---

 dlls/mshtml/navigate.c |   73 +++++++++++++++++++++++++++--------------------
 1 files changed, 42 insertions(+), 31 deletions(-)

diff --git a/dlls/mshtml/navigate.c b/dlls/mshtml/navigate.c
index 935a3b9..3f83456 100644
--- a/dlls/mshtml/navigate.c
+++ b/dlls/mshtml/navigate.c
@@ -638,6 +638,39 @@ static void call_docview_84(HTMLDocumentObj *doc)
         FIXME("handle result\n");
 }
 
+static HRESULT parse_headers(const WCHAR *headers, struct list *headers_list)
+{
+    const WCHAR *header, *header_end, *colon, *value;
+    HRESULT hres;
+
+    header = headers;
+    while(*header) {
+        if(header[0] == '\r' && header[1] == '\n' && !header[2])
+            break;
+        for(colon = header; *colon && *colon != ':' && *colon != '\r'; colon++);
+        if(*colon != ':')
+            return E_FAIL;
+
+        value = colon+1;
+        while(*value == ' ')
+            value++;
+        if(!*value)
+            return E_FAIL;
+
+        for(header_end = value+1; *header_end && *header_end != '\r'; header_end++);
+
+        hres = set_http_header(headers_list, header, colon-header, value, header_end-value);
+        if(FAILED(hres))
+            return hres;
+
+        header = header_end;
+        if(header[0] == '\r' && header[1] == '\n')
+            header += 2;
+    }
+
+    return S_OK;
+}
+
 static void parse_post_data(nsIInputStream *post_data_stream, LPWSTR *headers_ret,
                             HGLOBAL *post_data_ret, ULONG *post_data_len_ret)
 {
@@ -1109,38 +1142,16 @@ static HRESULT nsChannelBSC_on_response(BSCallback *bsc, DWORD response_code,
     This->nschannel->response_status = response_code;
 
     if(response_headers) {
-        const WCHAR *hdr_start, *hdr_end;
-
-        hdr_start = strchrW(response_headers, '\r');
-        while(hdr_start) {
-            const WCHAR *colon, *value;
-
-            hdr_start += 2;
-            hdr_end = strchrW(hdr_start, '\r');
-            if(!hdr_end) {
-                WARN("Header doesn't end with CRLF: %s\n", wine_dbgstr_w(hdr_start));
-                break;
-            }
-            if(hdr_end == hdr_start)
-                break;
-
-            for(colon = hdr_start; *colon != ':' && colon != hdr_end; ++colon);
-            if(*colon != ':') {
-                WARN("Header missing colon: %s\n", wine_dbgstr_w(hdr_start));
-                hdr_start = strchrW(hdr_start, '\r');
-                continue;
-            }
-
-            value = colon+1;
-            while(*value == ' ')
-                value++;
-
-            hres = set_http_header(&This->nschannel->response_headers, hdr_start, colon-hdr_start,
-                    value, hdr_end-value);
-            if(FAILED(hres))
+        const WCHAR *headers;
+
+        headers = strchrW(response_headers, '\r');
+        if(headers && headers[1] == '\n') {
+            headers += 2;
+            hres = parse_headers(headers, &This->nschannel->response_headers);
+            if(FAILED(hres)) {
+                WARN("parsing headers failed: %08x\n", hres);
                 return hres;
-
-            hdr_start = strchrW(hdr_start, '\r');
+            }
         }
     }
 




More information about the wine-cvs mailing list