static HRESULT WINAPI HTMLXMLHttpRequest_setRequestHeader(IHTMLXMLHttpRequest *iface, BSTR bstrHeader, BSTR bstrValue) { HTMLXMLHttpRequest *This = impl_from_IHTMLXMLHttpRequest(iface); 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 HRESULT WINAPI HTMLXMLHttpRequest_getResponseHeader(IHTMLXMLHttpRequest *iface, BSTR bstrHeader, BSTR *p) { HTMLXMLHttpRequest *This = impl_from_IHTMLXMLHttpRequest(iface); nsACString header, ret; char *cstr; nsresult nsres; HRESULT hres; LONG state; TRACE("(%p)->(%s %p)\n", This, debugstr_w(bstrHeader), p); if(!p) return E_POINTER; if(!bstrHeader) return E_INVALIDARG; hres = IHTMLXMLHttpRequest_get_readyState(iface, &state); if(FAILED(hres)) return hres; if(state < 2) { *p = NULL; return E_FAIL; } cstr = heap_strdupWtoU(bstrHeader); nsACString_InitDepend(&header, cstr); nsACString_Init(&ret, NULL); nsres = nsIXMLHttpRequest_GetResponseHeader(This->nsxhr, &header, &ret); nsACString_Finish(&header); heap_free(cstr); return return_nscstr(nsres, &ret, p); }
static HRESULT bstr_to_nsacstr(BSTR bstr, nsACString *str) { char *cstr = heap_strdupWtoU(bstr); if(!cstr) return E_OUTOFMEMORY; nsACString_Init(str, cstr); heap_free(cstr); return S_OK; }