| 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/test/embedded_test_server/http_request.h" | 5 #include "net/test/embedded_test_server/http_request.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 // Request main main header, eg. GET /foobar.html HTTP/1.1 | 86 // Request main main header, eg. GET /foobar.html HTTP/1.1 |
| 87 std::string request_headers; | 87 std::string request_headers; |
| 88 { | 88 { |
| 89 const std::string header_line = ShiftLine(); | 89 const std::string header_line = ShiftLine(); |
| 90 http_request_->all_headers += header_line + "\r\n"; | 90 http_request_->all_headers += header_line + "\r\n"; |
| 91 std::vector<std::string> header_line_tokens = base::SplitString( | 91 std::vector<std::string> header_line_tokens = base::SplitString( |
| 92 header_line, " ", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); | 92 header_line, " ", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); |
| 93 DCHECK_EQ(3u, header_line_tokens.size()); | 93 DCHECK_EQ(3u, header_line_tokens.size()); |
| 94 // Method. | 94 // Method. |
| 95 http_request_->method_string = header_line_tokens[0]; | 95 http_request_->method_string = header_line_tokens[0]; |
| 96 http_request_->method = GetMethodType(base::StringToLowerASCII( | 96 http_request_->method = |
| 97 header_line_tokens[0])); | 97 GetMethodType(base::ToLowerASCII(header_line_tokens[0])); |
| 98 // Address. | 98 // Address. |
| 99 // Don't build an absolute URL as the parser does not know (should not | 99 // Don't build an absolute URL as the parser does not know (should not |
| 100 // know) anything about the server address. | 100 // know) anything about the server address. |
| 101 http_request_->relative_url = header_line_tokens[1]; | 101 http_request_->relative_url = header_line_tokens[1]; |
| 102 // Protocol. | 102 // Protocol. |
| 103 const std::string protocol = | 103 const std::string protocol = base::ToLowerASCII(header_line_tokens[2]); |
| 104 base::StringToLowerASCII(header_line_tokens[2]); | |
| 105 CHECK(protocol == "http/1.0" || protocol == "http/1.1") << | 104 CHECK(protocol == "http/1.0" || protocol == "http/1.1") << |
| 106 "Protocol not supported: " << protocol; | 105 "Protocol not supported: " << protocol; |
| 107 } | 106 } |
| 108 | 107 |
| 109 // Parse further headers. | 108 // Parse further headers. |
| 110 { | 109 { |
| 111 std::string header_name; | 110 std::string header_name; |
| 112 while (true) { | 111 while (true) { |
| 113 std::string header_line = ShiftLine(); | 112 std::string header_line = ShiftLine(); |
| 114 if (header_line.empty()) | 113 if (header_line.empty()) |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 return METHOD_DELETE; | 224 return METHOD_DELETE; |
| 226 } else if (token == "patch") { | 225 } else if (token == "patch") { |
| 227 return METHOD_PATCH; | 226 return METHOD_PATCH; |
| 228 } | 227 } |
| 229 NOTREACHED() << "Method not implemented: " << token; | 228 NOTREACHED() << "Method not implemented: " << token; |
| 230 return METHOD_UNKNOWN; | 229 return METHOD_UNKNOWN; |
| 231 } | 230 } |
| 232 | 231 |
| 233 } // namespace test_server | 232 } // namespace test_server |
| 234 } // namespace net | 233 } // namespace net |
| OLD | NEW |