Bug 1339153 - Part 1: Correctly emulate missing headers in nsViewSourceChannel::GetResponseHeader, r=bz a=gchang
authorMichael Layzell <michael@thelayzells.com>
Mon, 13 Feb 2017 13:57:39 -0500
changeset 376152 ce38b7c201f7108e1e6e1c3f0084248d080b0260
parent 376151 8e53e1a9964baa87965e59d53d2882deff62d3ff
child 376153 d3e8e5d29deebaf206e50a9cefff6e08b2106a75
push id6996
push userjlorenzo@mozilla.com
push dateMon, 06 Mar 2017 20:48:21 +0000
treeherdermozilla-beta@d89512dab048 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz, gchang
bugs1339153
milestone53.0a2
Bug 1339153 - Part 1: Correctly emulate missing headers in nsViewSourceChannel::GetResponseHeader, r=bz a=gchang 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)