Bug 1339153 - Part 1: Correctly emulate missing headers in nsViewSourceChannel::GetResponseHeader, r=bz draft
authorMichael Layzell <michael@thelayzells.com>
Mon, 13 Feb 2017 13:57:39 -0500
changeset 485887 33c75f7e5480f14fc2cc7c596a96e4905d6fe5e0
parent 485886 46f696855363513262286105223a0d3d86b0f510
child 485888 9951109f1e7883e24ba58afa4e425f68e8e610b8
push id45870
push userbmo:kechen@mozilla.com
push dateFri, 17 Feb 2017 09:36:54 +0000
reviewersbz
bugs1339153
milestone54.0a1
Bug 1339153 - Part 1: Correctly emulate missing headers in nsViewSourceChannel::GetResponseHeader, r=bz MozReview-Commit-ID: 34bCA7wKkmh
netwerk/protocol/viewsource/nsViewSourceChannel.cpp
--- a/netwerk/protocol/viewsource/nsViewSourceChannel.cpp
+++ b/netwerk/protocol/viewsource/nsViewSourceChannel.cpp
@@ -902,17 +902,21 @@ nsViewSourceChannel::GetResponseHeader(c
     if (!aHeader.Equals(NS_LITERAL_CSTRING("Content-Type"),
                         nsCaseInsensitiveCStringComparator()) &&
         !aHeader.Equals(NS_LITERAL_CSTRING("Content-Security-Policy"),
                         nsCaseInsensitiveCStringComparator()) &&
         !aHeader.Equals(NS_LITERAL_CSTRING("Content-Security-Policy-Report-Only"),
                         nsCaseInsensitiveCStringComparator()) &&
         !aHeader.Equals(NS_LITERAL_CSTRING("X-Frame-Options"),
                         nsCaseInsensitiveCStringComparator())) {
-        return NS_OK;
+        // We simulate the NS_ERROR_NOT_AVAILABLE error which is produced by
+        // GetResponseHeader via nsHttpHeaderArray::GetHeader when the entry is
+        // not present, such that it appears as though no headers except for the
+        // whitelisted ones were set on this channel.
+        return NS_ERROR_NOT_AVAILABLE;
     }
 
     return mHttpChannel->GetResponseHeader(aHeader, aValue);
 }
 
 NS_IMETHODIMP
 nsViewSourceChannel::SetResponseHeader(const nsACString & header,
                                        const nsACString & value, bool merge)