Jacek Caban : mshtml: Store request headers in nsChannel if possible.

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


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

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

mshtml: Store request headers in nsChannel if possible.

---

 dlls/mshtml/mshtml_private.h |    1 +
 dlls/mshtml/navigate.c       |   69 ++++++++++++++++++++++++++++++++++++++++--
 dlls/mshtml/nsio.c           |    2 +
 3 files changed, 69 insertions(+), 3 deletions(-)

diff --git a/dlls/mshtml/mshtml_private.h b/dlls/mshtml/mshtml_private.h
index d1d0d05..fcdb792 100644
--- a/dlls/mshtml/mshtml_private.h
+++ b/dlls/mshtml/mshtml_private.h
@@ -464,6 +464,7 @@ typedef struct {
     char *charset;
     PRUint32 response_status;
     struct list response_headers;
+    struct list request_headers;
     UINT url_scheme;
 } nsChannel;
 
diff --git a/dlls/mshtml/navigate.c b/dlls/mshtml/navigate.c
index fc37f4d..239fbea 100644
--- a/dlls/mshtml/navigate.c
+++ b/dlls/mshtml/navigate.c
@@ -1090,9 +1090,18 @@ static HRESULT nsChannelBSC_init_bindinfo(BSCallback *bsc)
     nsChannelBSC *This = NSCHANNELBSC_THIS(bsc);
 
     if(This->nschannel && This->nschannel->post_data_stream) {
-        parse_post_data(This->nschannel->post_data_stream, &This->bsc.headers, &This->bsc.post_data, &This->bsc.post_data_len);
-        TRACE("headers = %s post_data = %s\n", debugstr_w(This->bsc.headers),
+        WCHAR *headers;
+        HRESULT hres;
+
+        parse_post_data(This->nschannel->post_data_stream, &headers, &This->bsc.post_data, &This->bsc.post_data_len);
+
+        TRACE("headers = %s post_data = %s\n", debugstr_w(headers),
               debugstr_an(This->bsc.post_data, This->bsc.post_data_len));
+
+        hres = parse_headers(headers, &This->nschannel->request_headers);
+        heap_free(headers);
+        if(FAILED(hres))
+            return hres;
     }
 
     return S_OK;
@@ -1174,7 +1183,51 @@ static HRESULT nsChannelBSC_on_response(BSCallback *bsc, DWORD response_code,
 
 static HRESULT nsChannelBSC_beginning_transaction(BSCallback *bsc, WCHAR **additional_headers)
 {
-    return S_FALSE;
+    nsChannelBSC *This = NSCHANNELBSC_THIS(bsc);
+    http_header_t *iter;
+    DWORD len = 0;
+    WCHAR *ptr;
+
+    static const WCHAR content_lengthW[] =
+        {'C','o','n','t','e','n','t','-','L','e','n','g','t','h',0};
+
+    if(!This->nschannel)
+        return S_FALSE;
+
+    LIST_FOR_EACH_ENTRY(iter, &This->nschannel->request_headers, http_header_t, entry) {
+        if(strcmpW(iter->header, content_lengthW))
+            len += strlenW(iter->header) + 2 /* ": " */ + strlenW(iter->data) + 2 /* "\r\n" */;
+    }
+
+    if(!len)
+        return S_OK;
+
+    *additional_headers = ptr = CoTaskMemAlloc((len+1)*sizeof(WCHAR));
+    if(!ptr)
+        return E_OUTOFMEMORY;
+
+    LIST_FOR_EACH_ENTRY(iter, &This->nschannel->request_headers, http_header_t, entry) {
+        if(!strcmpW(iter->header, content_lengthW))
+            continue;
+
+        len = strlenW(iter->header);
+        memcpy(ptr, iter->header, len*sizeof(WCHAR));
+        ptr += len;
+
+        *ptr++ = ':';
+        *ptr++ = ' ';
+
+        len = strlenW(iter->data);
+        memcpy(ptr, iter->data, len*sizeof(WCHAR));
+        ptr += len;
+
+        *ptr++ = '\r';
+        *ptr++ = '\n';
+    }
+
+    *ptr = 0;
+
+    return S_OK;
 }
 
 #undef NSCHANNELBSC_THIS
@@ -1325,6 +1378,16 @@ void channelbsc_set_channel(nsChannelBSC *This, nsChannel *channel, nsIStreamLis
         nsISupports_AddRef(context);
         This->nscontext = context;
     }
+
+    if(This->bsc.headers) {
+        HRESULT hres;
+
+        hres = parse_headers(This->bsc.headers, &channel->request_headers);
+        heap_free(This->bsc.headers);
+        This->bsc.headers = NULL;
+        if(FAILED(hres))
+            WARN("parse_headers failed: %08x\n", hres);
+    }
 }
 
 HRESULT hlink_frame_navigate(HTMLDocument *doc, LPCWSTR url,
diff --git a/dlls/mshtml/nsio.c b/dlls/mshtml/nsio.c
index 9bef7f0..09e125f 100644
--- a/dlls/mshtml/nsio.c
+++ b/dlls/mshtml/nsio.c
@@ -465,6 +465,7 @@ static nsrefcnt NSAPI nsChannel_Release(nsIHttpChannel *iface)
             nsIURI_Release(This->original_uri);
 
         free_http_headers(&This->response_headers);
+        free_http_headers(&This->request_headers);
 
         heap_free(This->content_type);
         heap_free(This->charset);
@@ -2611,6 +2612,7 @@ static nsresult NSAPI nsIOService_NewChannelFromURI(nsIIOService *iface, nsIURI
     ret->ref = 1;
     ret->uri = wine_uri;
     list_init(&ret->response_headers);
+    list_init(&ret->request_headers);
 
     nsIURI_AddRef(aURI);
     ret->original_uri = aURI;




More information about the wine-cvs mailing list