mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 726434 - Return DOMString for XMLHttpRequest.getAllResponseHeaders(); r=bent
This commit is contained in:
parent
a8e72a0529
commit
4a1b92efc5
@ -183,9 +183,9 @@ interface nsIXMLHttpRequest : nsISupports
|
||||
* part of a multipart request, not from the original channel.
|
||||
*
|
||||
* @returns A string containing all of the response headers.
|
||||
* NULL if the response has not yet been received.
|
||||
* The empty string if the response has not yet been received.
|
||||
*/
|
||||
string getAllResponseHeaders();
|
||||
DOMString getAllResponseHeaders();
|
||||
|
||||
/**
|
||||
* Returns the text of the header with the specified name for
|
||||
|
@ -1317,54 +1317,47 @@ nsXMLHttpRequest::Abort()
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* string getAllResponseHeaders (); */
|
||||
/* DOMString getAllResponseHeaders(); */
|
||||
NS_IMETHODIMP
|
||||
nsXMLHttpRequest::GetAllResponseHeaders(char **_retval)
|
||||
nsXMLHttpRequest::GetAllResponseHeaders(nsAString& aResponseHeaders)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(_retval);
|
||||
*_retval = nsnull;
|
||||
aResponseHeaders.Truncate();
|
||||
|
||||
// If the state is UNSENT or OPENED,
|
||||
// return the empty string and terminate these steps.
|
||||
if (mState & (XML_HTTP_REQUEST_UNSENT |
|
||||
XML_HTTP_REQUEST_OPENED | XML_HTTP_REQUEST_SENT)) {
|
||||
*_retval = ToNewCString(EmptyString());
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
if (mState & XML_HTTP_REQUEST_USE_XSITE_AC) {
|
||||
*_retval = ToNewCString(EmptyString());
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIHttpChannel> httpChannel = GetCurrentHttpChannel();
|
||||
|
||||
if (httpChannel) {
|
||||
if (nsCOMPtr<nsIHttpChannel> httpChannel = GetCurrentHttpChannel()) {
|
||||
nsRefPtr<nsHeaderVisitor> visitor = new nsHeaderVisitor();
|
||||
nsresult rv = httpChannel->VisitResponseHeaders(visitor);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
*_retval = ToNewCString(visitor->Headers());
|
||||
} else if (mChannel) {
|
||||
// Even non-http channels supply content type.
|
||||
nsCString value;
|
||||
if (NS_SUCCEEDED(mChannel->GetContentType(value))) {
|
||||
nsCString headers;
|
||||
headers.Append("Content-Type: ");
|
||||
headers.Append(value);
|
||||
if (NS_SUCCEEDED(mChannel->GetContentCharset(value)) &&
|
||||
!value.IsEmpty()) {
|
||||
headers.Append(";charset=");
|
||||
headers.Append(value);
|
||||
}
|
||||
headers.Append('\n');
|
||||
*_retval = ToNewCString(headers);
|
||||
if (NS_SUCCEEDED(httpChannel->VisitResponseHeaders(visitor))) {
|
||||
aResponseHeaders = NS_ConvertUTF8toUTF16(visitor->Headers());
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
if (!*_retval) {
|
||||
*_retval = ToNewCString(EmptyString());
|
||||
if (!mChannel) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Even non-http channels supply content type.
|
||||
nsCAutoString value;
|
||||
if (NS_SUCCEEDED(mChannel->GetContentType(value))) {
|
||||
aResponseHeaders.AppendLiteral("Content-Type: ");
|
||||
aResponseHeaders.Append(NS_ConvertUTF8toUTF16(value));
|
||||
if (NS_SUCCEEDED(mChannel->GetContentCharset(value)) &&
|
||||
!value.IsEmpty()) {
|
||||
aResponseHeaders.AppendLiteral(";charset=");
|
||||
aResponseHeaders.Append(NS_ConvertUTF8toUTF16(value));
|
||||
}
|
||||
aResponseHeaders.Append('\n');
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -916,11 +916,11 @@ public:
|
||||
|
||||
class GetAllResponseHeadersRunnable : public WorkerThreadProxySyncRunnable
|
||||
{
|
||||
nsCString& mResponseHeaders;
|
||||
nsString& mResponseHeaders;
|
||||
|
||||
public:
|
||||
GetAllResponseHeadersRunnable(WorkerPrivate* aWorkerPrivate, Proxy* aProxy,
|
||||
nsCString& aResponseHeaders)
|
||||
nsString& aResponseHeaders)
|
||||
: WorkerThreadProxySyncRunnable(aWorkerPrivate, aProxy),
|
||||
mResponseHeaders(aResponseHeaders)
|
||||
{ }
|
||||
@ -929,7 +929,7 @@ public:
|
||||
MainThreadRun()
|
||||
{
|
||||
nsresult rv =
|
||||
mProxy->mXHR->GetAllResponseHeaders(getter_Copies(mResponseHeaders));
|
||||
mProxy->mXHR->GetAllResponseHeaders(mResponseHeaders);
|
||||
return GetDOMExceptionCodeFromResult(rv);
|
||||
}
|
||||
};
|
||||
@ -1613,15 +1613,15 @@ XMLHttpRequestPrivate::GetAllResponseHeaders(JSContext* aCx)
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
nsCString responseHeaders;
|
||||
nsString responseHeaders;
|
||||
nsRefPtr<GetAllResponseHeadersRunnable> runnable =
|
||||
new GetAllResponseHeadersRunnable(mWorkerPrivate, mProxy, responseHeaders);
|
||||
if (!runnable->Dispatch(aCx)) {
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
return JS_NewStringCopyN(aCx, responseHeaders.get(),
|
||||
responseHeaders.Length());
|
||||
return JS_NewUCStringCopyN(aCx, responseHeaders.get(),
|
||||
responseHeaders.Length());
|
||||
}
|
||||
|
||||
JSString*
|
||||
|
Loading…
Reference in New Issue
Block a user