 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..419d4ff2739f7c17cc51ddddc6de336e933588d3 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 { | 
| @@ -35,6 +36,10 @@ HttpRequest::HttpRequest() : method(METHOD_UNKNOWN), | 
| HttpRequest::~HttpRequest() { | 
| } | 
| +GURL HttpRequest::ToURL() const { | 
| + return GURL("http://localhost" + relative_url); | 
| 
mmenke
2015/10/19 18:07:40
Could you add a TODO to consider making this retur
 
svaldez
2015/10/19 21:56:15
Done.
 | 
| +} | 
| + | 
| HttpRequestParser::HttpRequestParser() | 
| : http_request_(new HttpRequest()), | 
| buffer_position_(0), | 
| @@ -98,7 +103,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()) { | 
| 
mmenke
2015/10/19 18:07:40
If we have a full URL, surely HttpRequest::ToURL s
 
svaldez
2015/10/19 21:56:15
There are cases where the "full URL" is actually n
 
mmenke
2015/10/21 18:45:22
Such as?
 | 
| + http_request_->relative_url = url.path(); | 
| + } else { | 
| + if (header_line_tokens[1][0] == '/') | 
| 
mmenke
2015/10/19 18:07:40
else if {
} else {
}
 
svaldez
2015/10/19 21:56:15
Done.
 | 
| + 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 +153,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."; | 
| 
mmenke
2015/10/19 18:07:40
We actually have tests that send invalid content-l
 
svaldez
2015/10/19 21:56:15
Some tests send Content-Length even if there isn't
 | 
| + } | 
| } else if (http_request_->headers.count("Transfer-Encoding") > 0) { | 
| if (http_request_->headers["Transfer-Encoding"] == "chunked") { | 
| http_request_->has_content = true; | 
| @@ -224,9 +241,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 |