From c694d1761b563a154d7b4a39c171698180dfa73f Mon Sep 17 00:00:00 2001 From: Thomas Wisniewski Date: Tue, 28 Jun 2016 19:22:16 -0400 Subject: [PATCH] Bug 924319 - do not include Content-Length for data URIs in XMLHttpRequest.getAllResponseHeaders. r=jst --HG-- extra : rebase_source : e4b966f7cfd054394cf8672e00b8b63feea9ce84 --- dom/xhr/XMLHttpRequestMainThread.cpp | 17 ++++++++++++----- .../meta/XMLHttpRequest/data-uri.htm.ini | 12 ------------ 2 files changed, 12 insertions(+), 17 deletions(-) diff --git a/dom/xhr/XMLHttpRequestMainThread.cpp b/dom/xhr/XMLHttpRequestMainThread.cpp index 385fc41b4bfa..5a1de699423d 100644 --- a/dom/xhr/XMLHttpRequestMainThread.cpp +++ b/dom/xhr/XMLHttpRequestMainThread.cpp @@ -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 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"); + } } } diff --git a/testing/web-platform/meta/XMLHttpRequest/data-uri.htm.ini b/testing/web-platform/meta/XMLHttpRequest/data-uri.htm.ini index 0e4fcf34eb69..ef0649f92c17 100644 --- a/testing/web-platform/meta/XMLHttpRequest/data-uri.htm.ini +++ b/testing/web-platform/meta/XMLHttpRequest/data-uri.htm.ini @@ -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