diff --git a/dlls/mshtml/binding.h b/dlls/mshtml/binding.h index c2daffd3f5f..e1734310028 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 87e41541db2..3cbaa24fe23 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 e1516d2949a..c22080dfa52 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 fd811e91cca..9bced996bde 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,