Bug 924319 - do not include Content-Length for data URIs in XMLHttpRequest.getAllResponseHeaders. r=jst

--HG--
extra : rebase_source : e4b966f7cfd054394cf8672e00b8b63feea9ce84
This commit is contained in:
Thomas Wisniewski 2016-06-28 19:22:16 -04:00
parent 30e61f3146
commit c694d1761b
2 changed files with 12 additions and 17 deletions

View File

@ -1182,11 +1182,18 @@ XMLHttpRequestMainThread::GetAllResponseHeaders(nsACString& aResponseHeaders,
aResponseHeaders.AppendLiteral("\r\n");
}
int64_t length;
if (NS_SUCCEEDED(mChannel->GetContentLength(&length))) {
aResponseHeaders.AppendLiteral("Content-Length: ");
aResponseHeaders.AppendInt(length);
aResponseHeaders.AppendLiteral("\r\n");
// Don't provide Content-Length for data URIs
nsCOMPtr<nsIURI> uri;
bool isDataURI;
if (NS_FAILED(mChannel->GetURI(getter_AddRefs(uri))) ||
NS_FAILED(uri->SchemeIs("data", &isDataURI)) ||
!isDataURI) {
int64_t length;
if (NS_SUCCEEDED(mChannel->GetContentLength(&length))) {
aResponseHeaders.AppendLiteral("Content-Length: ");
aResponseHeaders.AppendInt(length);
aResponseHeaders.AppendLiteral("\r\n");
}
}
}

View File

@ -1,17 +1,5 @@
[data-uri.htm]
type: testharness
[XHR method GET with charset text/plain]
expected: FAIL
[XHR method GET with charset text/plain (base64)]
expected: FAIL
[XHR method GET with charset text/html]
expected: FAIL
[XHR method GET with charset text/html;charset=UTF-8]
expected: FAIL
[XHR method GET with charset image/png]
expected: FAIL