Zhenbo Li : mshtml: Add nsChannel_GetResponseStatusText implementation.

Alexandre Julliard julliard at wine.codeweavers.com
Wed Jul 22 13:40:43 CDT 2015


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

Author: Zhenbo Li <litimetal at gmail.com>
Date:   Wed Jul 22 23:34:12 2015 +0800

mshtml: Add nsChannel_GetResponseStatusText implementation.

---

 dlls/mshtml/binding.h        |  1 +
 dlls/mshtml/mshtml_private.h | 17 +++++++++++++++++
 dlls/mshtml/navigate.c       | 28 ++++++++++++++++++++++++++++
 dlls/mshtml/nsio.c           |  5 +++--
 4 files changed, 49 insertions(+), 2 deletions(-)

diff --git a/dlls/mshtml/binding.h b/dlls/mshtml/binding.h
index c2daffd..e173431 100644
--- a/dlls/mshtml/binding.h
+++ b/dlls/mshtml/binding.h
@@ -51,6 +51,7 @@ typedef struct {
     char *content_type;
     char *charset;
     UINT32 response_status;
+    char *response_status_text;
     REQUEST_METHOD request_method;
     struct list response_headers;
     struct list request_headers;
diff --git a/dlls/mshtml/mshtml_private.h b/dlls/mshtml/mshtml_private.h
index 87e4154..3cbaa24 100644
--- a/dlls/mshtml/mshtml_private.h
+++ b/dlls/mshtml/mshtml_private.h
@@ -1230,6 +1230,23 @@ static inline char *heap_strdupWtoU(const WCHAR *str)
     return ret;
 }
 
+static inline char *heap_strndupWtoU(LPCWSTR str, unsigned len)
+{
+    char *ret = NULL;
+    DWORD size;
+
+    if(str && len) {
+        size = WideCharToMultiByte(CP_UTF8, 0, str, len, NULL, 0, NULL, NULL);
+        ret = heap_alloc(size + 1);
+        if(ret) {
+            WideCharToMultiByte(CP_UTF8, 0, str, len, ret, size, NULL, NULL);
+            ret[size] = '\0';
+        }
+    }
+
+    return ret;
+}
+
 static inline void windowref_addref(windowref_t *ref)
 {
     InterlockedIncrement(&ref->ref);
diff --git a/dlls/mshtml/navigate.c b/dlls/mshtml/navigate.c
index e1516d2..c22080d 100644
--- a/dlls/mshtml/navigate.c
+++ b/dlls/mshtml/navigate.c
@@ -1595,10 +1595,29 @@ static HRESULT nsChannelBSC_on_progress(BSCallback *bsc, ULONG status_code, LPCW
     return S_OK;
 }
 
+static HRESULT process_response_status_text(const WCHAR *header, const WCHAR *header_end, char **status_text)
+{
+    header = strchrW(header + 1, ' ');
+    if(!header || header >= header_end)
+        return E_FAIL;
+    header = strchrW(header + 1, ' ');
+    if(!header || header >= header_end)
+        return E_FAIL;
+    ++header;
+
+    *status_text = heap_strndupWtoU(header, header_end - header);
+
+    if(!*status_text)
+        return E_OUTOFMEMORY;
+
+    return S_OK;
+}
+
 static HRESULT nsChannelBSC_on_response(BSCallback *bsc, DWORD response_code,
         LPCWSTR response_headers)
 {
     nsChannelBSC *This = nsChannelBSC_from_BSCallback(bsc);
+    char *str;
     HRESULT hres;
 
     This->response_processed = TRUE;
@@ -1608,6 +1627,15 @@ static HRESULT nsChannelBSC_on_response(BSCallback *bsc, DWORD response_code,
         const WCHAR *headers;
 
         headers = strchrW(response_headers, '\r');
+        hres = process_response_status_text(response_headers, headers, &str);
+        if(FAILED(hres)) {
+            WARN("parsing headers failed: %08x\n", hres);
+            return hres;
+        }
+
+        heap_free(This->nschannel->response_status_text);
+        This->nschannel->response_status_text = str;
+
         if(headers && headers[1] == '\n') {
             headers += 2;
             hres = process_response_headers(This, headers);
diff --git a/dlls/mshtml/nsio.c b/dlls/mshtml/nsio.c
index fd811e9..9bced99 100644
--- a/dlls/mshtml/nsio.c
+++ b/dlls/mshtml/nsio.c
@@ -1394,9 +1394,10 @@ static nsresult NSAPI nsChannel_GetResponseStatusText(nsIHttpChannel *iface,
 {
     nsChannel *This = impl_from_nsIHttpChannel(iface);
 
-    FIXME("(%p)->(%p)\n", This, aResponseStatusText);
+    TRACE("(%p)->(%p)\n", This, aResponseStatusText);
 
-    return NS_ERROR_NOT_IMPLEMENTED;
+    nsACString_SetData(aResponseStatusText, This->response_status_text);
+    return NS_OK;
 }
 
 static nsresult NSAPI nsChannel_GetRequestSucceeded(nsIHttpChannel *iface,




More information about the wine-cvs mailing list