Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(203)

Unified Diff: net/http/http_stream_parser.cc

Issue 2665603003: Add detection of Shoutcast responses and accept them as valid HTTP/0.9 (Closed)
Patch Set: Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | net/http/http_stream_parser_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/http/http_stream_parser.cc
diff --git a/net/http/http_stream_parser.cc b/net/http/http_stream_parser.cc
index 59b15e03aabfb3712c91170decd1e62dd1620b53..7da5adaf13d19dd90039a6de552c979e7a22dddf 100644
--- a/net/http/http_stream_parser.cc
+++ b/net/http/http_stream_parser.cc
@@ -968,13 +968,19 @@ int HttpStreamParser::ParseResponseHeaders(int end_offset) {
// If the port is not the default for the scheme, assume it's not a real
// HTTP/0.9 response, and fail the request.
- // TODO(crbug.com/624462): Further restrict the cases in which we allow
- // HTTP/0.9.
- std::string scheme(request_->url.scheme());
+ base::StringPiece scheme = request_->url.scheme_piece();
if (!http_09_on_non_default_ports_enabled_ &&
- url::DefaultPortForScheme(scheme.c_str(), scheme.length()) !=
+ url::DefaultPortForScheme(scheme.data(), scheme.length()) !=
request_->url.EffectiveIntPort()) {
- return ERR_INVALID_HTTP_RESPONSE;
+ // Allow Shoutcast responses over HTTP, as it's somewhat common and relies
+ // on HTTP/0.9 on weird ports to work.
+ // See
+ // https://groups.google.com/a/chromium.org/forum/#!topic/blink-dev/qS63pYso4P0
+ if (read_buf_->offset() < 3 || scheme != "http" ||
+ !base::LowerCaseEqualsASCII(
+ base::StringPiece(read_buf_->StartOfBuffer(), 3), "icy")) {
+ return ERR_INVALID_HTTP_RESPONSE;
+ }
}
headers = new HttpResponseHeaders(std::string("HTTP/0.9 200 OK"));
« no previous file with comments | « no previous file | net/http/http_stream_parser_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698