 Chromium Code Reviews
 Chromium Code Reviews Issue 1376593007:
  SSL in EmbeddedTestServer  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/src.git@master
    
  
    Issue 1376593007:
  SSL in EmbeddedTestServer  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/src.git@master| Index: net/test/embedded_test_server/http_request.cc | 
| diff --git a/net/test/embedded_test_server/http_request.cc b/net/test/embedded_test_server/http_request.cc | 
| index 9e0c80f96fa092aa2ce05dee5975ba9c68734625..6640538225b8193842d36805d906670b1cf9b192 100644 | 
| --- a/net/test/embedded_test_server/http_request.cc | 
| +++ b/net/test/embedded_test_server/http_request.cc | 
| @@ -11,6 +11,7 @@ | 
| #include "base/strings/string_number_conversions.h" | 
| #include "base/strings/string_split.h" | 
| #include "net/http/http_chunked_decoder.h" | 
| +#include "url/gurl.h" | 
| namespace net { | 
| namespace test_server { | 
| @@ -98,7 +99,16 @@ HttpRequestParser::ParseResult HttpRequestParser::ParseHeaders() { | 
| // Address. | 
| // Don't build an absolute URL as the parser does not know (should not | 
| // know) anything about the server address. | 
| - http_request_->relative_url = header_line_tokens[1]; | 
| + GURL url(header_line_tokens[1]); | 
| + if (url.is_valid()) | 
| + http_request_->relative_url = url.path(); | 
| 
davidben
2015/10/13 19:43:48
Nit: curlies (if not having curlies and else havin
 
svaldez
2015/10/13 20:54:44
Done.
 | 
| + else { | 
| + if (header_line_tokens[1][0] == '/') | 
| + http_request_->relative_url = header_line_tokens[1]; | 
| + else | 
| + http_request_->relative_url = "/" + header_line_tokens[1]; | 
| + } | 
| + | 
| // Protocol. | 
| const std::string protocol = base::ToLowerASCII(header_line_tokens[2]); | 
| CHECK(protocol == "http/1.0" || protocol == "http/1.1") << | 
| @@ -139,7 +149,10 @@ HttpRequestParser::ParseResult HttpRequestParser::ParseHeaders() { | 
| const bool success = base::StringToSizeT( | 
| http_request_->headers["Content-Length"], | 
| &declared_content_length_); | 
| - DCHECK(success) << "Malformed Content-Length header's value."; | 
| + if (!success) { | 
| + declared_content_length_ = 0; | 
| + LOG(WARNING) << "Malformed Content-Length header's value."; | 
| 
davidben
2015/10/13 19:43:48
Why this change?
 
svaldez
2015/10/13 20:54:44
"Content-Length: " turns out to be a valid header
 | 
| + } | 
| } else if (http_request_->headers.count("Transfer-Encoding") > 0) { | 
| if (http_request_->headers["Transfer-Encoding"] == "chunked") { | 
| http_request_->has_content = true; | 
| @@ -224,9 +237,11 @@ HttpMethod HttpRequestParser::GetMethodType(const std::string& token) const { | 
| return METHOD_DELETE; | 
| } else if (token == "patch") { | 
| return METHOD_PATCH; | 
| + } else if (token == "connect") { | 
| + return METHOD_CONNECT; | 
| } | 
| - NOTREACHED() << "Method not implemented: " << token; | 
| - return METHOD_UNKNOWN; | 
| + LOG(WARNING) << "Method not implemented: " << token; | 
| + return METHOD_GET; | 
| } | 
| } // namespace test_server |