mshtml: Add nsChannel_GetResponseStatusText implementation.

oldstable
Zhenbo Li 2015-07-22 23:34:12 +08:00 committed by Alexandre Julliard
parent 21043e5acf
commit 4e6e9a1485
4 changed files with 49 additions and 2 deletions

View File

@ -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;

View File

@ -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);

View File

@ -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);

View File

@ -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,