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

Unified Diff: net/http/http_stream_parser.cc

Issue 2648253004: 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') | net/http/http_stream_parser_unittest.cc » ('J')
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..a265fa20da9e3a6edc45476d524e8d276e0166ec 100644
--- a/net/http/http_stream_parser.cc
+++ b/net/http/http_stream_parser.cc
@@ -968,13 +968,17 @@ 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());
eroman 2017/01/24 00:37:29 [optional] style-nit: use assignment
mmenke 2017/01/24 17:27:02 Done. I find I tend to default to this style beca
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 through, as it's somewhat common
eroman 2017/01/24 00:37:29 nit: delete "through" as it feels redundant with "
mmenke 2017/01/24 17:27:02 Done.
+ // and relies on HTTP/0.9 on weird ports to work.
eroman 2017/01/24 00:37:29 Can you add a link to an explanation of what the i
mmenke 2017/01/24 17:27:02 Done, link to the intent to implement (Bug has way
+ 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') | net/http/http_stream_parser_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698