Nikolay Sivov : msxml3: Implemented IXMLHttpRequest::get_statusText().
Alexandre Julliard
julliard at winehq.org
Wed Jan 18 14:03:41 CST 2012
Module: wine
Branch: master
Commit: 95d8f6fc2c879947e68ea14e76d69822403c56b0
URL: http://source.winehq.org/git/wine.git/?a=commit;h=95d8f6fc2c879947e68ea14e76d69822403c56b0
Author: Nikolay Sivov <nsivov at codeweavers.com>
Date: Wed Jan 18 03:04:22 2012 +0300
msxml3: Implemented IXMLHttpRequest::get_statusText().
---
dlls/msxml3/httprequest.c | 32 +++++++++++++++++++++++++++-----
dlls/msxml3/tests/domdoc.c | 11 +++++++++++
2 files changed, 38 insertions(+), 5 deletions(-)
diff --git a/dlls/msxml3/httprequest.c b/dlls/msxml3/httprequest.c
index f2e8b5e..99b7672 100644
--- a/dlls/msxml3/httprequest.c
+++ b/dlls/msxml3/httprequest.c
@@ -98,6 +98,7 @@ typedef struct
/* bind callback */
BindStatusCallback *bsc;
LONG status;
+ BSTR status_text;
/* IObjectWithSite*/
IUnknown *site;
@@ -517,8 +518,10 @@ static HRESULT WINAPI BSCHttpNegotiate_OnResponse(IHttpNegotiate *iface, DWORD c
debugstr_w(req_headers), add_reqheaders);
This->request->status = code;
- /* store headers */
+ /* store headers and status text */
free_response_headers(This->request);
+ SysFreeString(This->request->status_text);
+ This->request->status_text = NULL;
if (resp_headers)
{
const WCHAR *ptr, *line;
@@ -530,7 +533,19 @@ static HRESULT WINAPI BSCHttpNegotiate_OnResponse(IHttpNegotiate *iface, DWORD c
{
if (*ptr == '\r' && *(ptr+1) == '\n')
{
- line = ++ptr+1;
+ const WCHAR *end = ptr-1;
+ line = ptr + 2;
+ /* scan back to get status phrase */
+ while (ptr > resp_headers)
+ {
+ if (*ptr == ' ')
+ {
+ This->request->status_text = SysAllocStringLen(ptr+1, end-ptr);
+ TRACE("status text %s\n", debugstr_w(This->request->status_text));
+ break;
+ }
+ ptr--;
+ }
break;
}
ptr++;
@@ -789,6 +804,7 @@ static ULONG WINAPI httprequest_Release(IXMLHTTPRequest *iface)
}
/* response headers */
free_response_headers(This);
+ SysFreeString(This->status_text);
/* detach callback object */
BindStatusCallback_Detach(This->bsc);
@@ -1093,13 +1109,18 @@ static HRESULT WINAPI httprequest_get_status(IXMLHTTPRequest *iface, LONG *statu
return S_OK;
}
-static HRESULT WINAPI httprequest_get_statusText(IXMLHTTPRequest *iface, BSTR *pbstrStatus)
+static HRESULT WINAPI httprequest_get_statusText(IXMLHTTPRequest *iface, BSTR *status)
{
httprequest *This = impl_from_IXMLHTTPRequest( iface );
- FIXME("stub %p %p\n", This, pbstrStatus);
+ TRACE("(%p)->(%p)\n", This, status);
- return E_NOTIMPL;
+ if (!status) return E_INVALIDARG;
+ if (This->state != READYSTATE_COMPLETE) return E_FAIL;
+
+ *status = SysAllocString(This->status_text);
+
+ return S_OK;
}
static HRESULT WINAPI httprequest_get_responseXML(IXMLHTTPRequest *iface, IDispatch **body)
@@ -1475,6 +1496,7 @@ HRESULT XMLHTTPRequest_create(IUnknown *pUnkOuter, void **ppObj)
req->bsc = NULL;
req->status = 0;
+ req->status_text = NULL;
req->reqheader_size = 0;
req->raw_respheaders = NULL;
req->use_utf8_content = FALSE;
diff --git a/dlls/msxml3/tests/domdoc.c b/dlls/msxml3/tests/domdoc.c
index 0041763..21809f8 100644
--- a/dlls/msxml3/tests/domdoc.c
+++ b/dlls/msxml3/tests/domdoc.c
@@ -4744,6 +4744,9 @@ static void test_XMLHTTP(void)
ok(hr == E_FAIL || broken(hr == E_UNEXPECTED) /* win2k */, "got 0x%08x\n", hr);
ok(status == 0xdeadbeef, "got %d\n", status);
+ hr = IXMLHttpRequest_get_statusText(xhr, &str);
+ ok(hr == E_FAIL, "got 0x%08x\n", hr);
+
/* invalid parameters */
hr = IXMLHttpRequest_open(xhr, NULL, NULL, async, dummy, dummy);
EXPECT_HR(hr, E_INVALIDARG);
@@ -4862,6 +4865,14 @@ static void test_XMLHTTP(void)
EXPECT_HR(hr, S_OK);
ok(status == 200, "got %d\n", status);
+ hr = IXMLHttpRequest_get_statusText(xhr, NULL);
+ EXPECT_HR(hr, E_INVALIDARG);
+
+ hr = IXMLHttpRequest_get_statusText(xhr, &str);
+ EXPECT_HR(hr, S_OK);
+ ok(!lstrcmpW(str, _bstr_("OK")), "got status %s\n", wine_dbgstr_w(str));
+ SysFreeString(str);
+
/* another ::send() after completed request */
V_VT(&varbody) = VT_BSTR;
V_BSTR(&varbody) = _bstr_(bodyA);
More information about the wine-cvs
mailing list