OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "net/http/http_network_transaction.h" | 5 #include "net/http/http_network_transaction.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include <set> | 8 #include <set> |
9 #include <utility> | 9 #include <utility> |
10 #include <vector> | 10 #include <vector> |
(...skipping 1783 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1794 FilterSourceStream::ReportContentDecodingFailed(SourceStream::TYPE_INVALID); | 1794 FilterSourceStream::ReportContentDecodingFailed(SourceStream::TYPE_INVALID); |
1795 return false; | 1795 return false; |
1796 } | 1796 } |
1797 | 1797 |
1798 // When "Accept-Encoding" is not specified, it is parsed as "*". | 1798 // When "Accept-Encoding" is not specified, it is parsed as "*". |
1799 // If "*" encoding is advertised, then any encoding should be "accepted". | 1799 // If "*" encoding is advertised, then any encoding should be "accepted". |
1800 // This does not mean, that it will be successfully decoded. | 1800 // This does not mean, that it will be successfully decoded. |
1801 if (allowed_encodings.find("*") != allowed_encodings.end()) | 1801 if (allowed_encodings.find("*") != allowed_encodings.end()) |
1802 return true; | 1802 return true; |
1803 | 1803 |
| 1804 bool result = true; |
1804 for (auto const& encoding : used_encodings) { | 1805 for (auto const& encoding : used_encodings) { |
1805 SourceStream::SourceType source_type = | 1806 SourceStream::SourceType source_type = |
1806 FilterSourceStream::ParseEncodingType(encoding); | 1807 FilterSourceStream::ParseEncodingType(encoding); |
1807 // We don't reject encodings we are not aware. They just will not decode. | 1808 // We don't reject encodings we are not aware. They just will not decode. |
1808 if (source_type == SourceStream::TYPE_UNKNOWN) | 1809 if (source_type == SourceStream::TYPE_UNKNOWN) |
1809 continue; | 1810 continue; |
1810 if (allowed_encodings.find(encoding) == allowed_encodings.end()) { | 1811 if (allowed_encodings.find(encoding) == allowed_encodings.end()) { |
1811 FilterSourceStream::ReportContentDecodingFailed(source_type); | 1812 FilterSourceStream::ReportContentDecodingFailed( |
1812 return false; | 1813 SourceStream::TYPE_REJECTED); |
| 1814 result = false; |
| 1815 break; |
1813 } | 1816 } |
1814 } | 1817 } |
1815 return true; | 1818 |
| 1819 // Temporary workaround for http://crbug.com/714514 |
| 1820 if (headers->IsRedirect(nullptr)) { |
| 1821 UMA_HISTOGRAM_BOOLEAN("Net.RedirectWithUnadvertisedContentEncoding", |
| 1822 !result); |
| 1823 return true; |
| 1824 } |
| 1825 |
| 1826 return result; |
1816 } | 1827 } |
1817 | 1828 |
1818 } // namespace net | 1829 } // namespace net |
OLD | NEW |