mshtml: Added IHTMLXMLHttpRequest::getResponseHeader implementation.

Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Jacek Caban 2016-02-24 18:53:10 +01:00 committed by Alexandre Julliard
parent 4361a1f090
commit 206bebfd8f
2 changed files with 46 additions and 2 deletions

View File

@ -524,6 +524,19 @@ static void test_illegal_xml(IXMLDOMDocument *xmldom)
ok(last == NULL, "last != NULL\n");
}
#define set_request_header(a,b,c) _set_request_header(__LINE__,a,b,c)
static void _set_request_header(unsigned line, IHTMLXMLHttpRequest *xhr, const char *header_a, const char *value_a)
{
BSTR header = a2bstr(header_a), value = a2bstr(value_a);
HRESULT hres;
hres = IHTMLXMLHttpRequest_setRequestHeader(xhr, header, value);
ok_(__FILE__,line)(hres == S_OK, "setRequestHeader failed: %08x\n", hres);
SysFreeString(header);
SysFreeString(value);
}
static void test_responseXML(const char *expect_text)
{
IDispatch *disp;
@ -673,6 +686,8 @@ static void test_sync_xhr(IHTMLDocument2 *doc, const char *xml_url, const char *
ok(hres == S_OK, "get_readyState failed: %08x\n", hres);
ok(val == 1, "Expect OPENED, got %d\n", val);
set_request_header(xhr, "x-wine-test", "sync-test");
SET_EXPECT(xmlhttprequest_onreadystatechange_opened);
SET_EXPECT(xmlhttprequest_onreadystatechange_headers_received);
SET_EXPECT(xmlhttprequest_onreadystatechange_loading);
@ -835,6 +850,8 @@ static void test_async_xhr(IHTMLDocument2 *doc, const char *xml_url, const char
ok(hres == S_OK, "get_readyState failed: %08x\n", hres);
ok(val == 1, "Expect OPENED, got %d\n", val);
set_request_header(xhr, "x-wine-test", "async-test");
SET_EXPECT(xmlhttprequest_onreadystatechange_opened);
SET_EXPECT(xmlhttprequest_onreadystatechange_headers_received);
SET_EXPECT(xmlhttprequest_onreadystatechange_loading);

View File

@ -613,8 +613,35 @@ static HRESULT WINAPI HTMLXMLHttpRequest_getResponseHeader(IHTMLXMLHttpRequest *
static HRESULT WINAPI HTMLXMLHttpRequest_setRequestHeader(IHTMLXMLHttpRequest *iface, BSTR bstrHeader, BSTR bstrValue)
{
HTMLXMLHttpRequest *This = impl_from_IHTMLXMLHttpRequest(iface);
FIXME("(%p)->(%s %s)\n", This, debugstr_w(bstrHeader), debugstr_w(bstrValue));
return E_NOTIMPL;
char *header_u, *value_u;
nsACString header, value;
nsresult nsres;
TRACE("(%p)->(%s %s)\n", This, debugstr_w(bstrHeader), debugstr_w(bstrValue));
header_u = heap_strdupWtoU(bstrHeader);
if(bstrHeader && !header_u)
return E_OUTOFMEMORY;
value_u = heap_strdupWtoU(bstrValue);
if(bstrValue && !value_u) {
heap_free(header_u);
return E_OUTOFMEMORY;
}
nsACString_InitDepend(&header, header_u);
nsACString_InitDepend(&value, value_u);
nsres = nsIXMLHttpRequest_SetRequestHeader(This->nsxhr, &header, &value);
nsACString_Finish(&header);
nsACString_Finish(&value);
heap_free(header_u);
heap_free(value_u);
if(NS_FAILED(nsres)) {
ERR("SetRequestHeader failed: %08x\n", nsres);
return E_FAIL;
}
return S_OK;
}
static const IHTMLXMLHttpRequestVtbl HTMLXMLHttpRequestVtbl = {