| 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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 return WAITING; | 82 return WAITING; |
| 83 | 83 |
| 84 // Parse request's the first header line. | 84 // Parse request's the first header line. |
| 85 // Request main main header, eg. GET /foobar.html HTTP/1.1 | 85 // Request main main header, eg. GET /foobar.html HTTP/1.1 |
| 86 { | 86 { |
| 87 const std::string header_line = ShiftLine(); | 87 const std::string header_line = ShiftLine(); |
| 88 std::vector<std::string> header_line_tokens; | 88 std::vector<std::string> header_line_tokens; |
| 89 base::SplitString(header_line, ' ', &header_line_tokens); | 89 base::SplitString(header_line, ' ', &header_line_tokens); |
| 90 DCHECK_EQ(3u, header_line_tokens.size()); | 90 DCHECK_EQ(3u, header_line_tokens.size()); |
| 91 // Method. | 91 // Method. |
| 92 http_request_->method = GetMethodType(StringToLowerASCII( | 92 http_request_->method = GetMethodType(base::StringToLowerASCII( |
| 93 header_line_tokens[0])); | 93 header_line_tokens[0])); |
| 94 // Address. | 94 // Address. |
| 95 // Don't build an absolute URL as the parser does not know (should not | 95 // Don't build an absolute URL as the parser does not know (should not |
| 96 // know) anything about the server address. | 96 // know) anything about the server address. |
| 97 http_request_->relative_url = header_line_tokens[1]; | 97 http_request_->relative_url = header_line_tokens[1]; |
| 98 // Protocol. | 98 // Protocol. |
| 99 const std::string protocol = StringToLowerASCII(header_line_tokens[2]); | 99 const std::string protocol = |
| 100 base::StringToLowerASCII(header_line_tokens[2]); |
| 100 CHECK(protocol == "http/1.0" || protocol == "http/1.1") << | 101 CHECK(protocol == "http/1.0" || protocol == "http/1.1") << |
| 101 "Protocol not supported: " << protocol; | 102 "Protocol not supported: " << protocol; |
| 102 } | 103 } |
| 103 | 104 |
| 104 // Parse further headers. | 105 // Parse further headers. |
| 105 { | 106 { |
| 106 std::string header_name; | 107 std::string header_name; |
| 107 while (true) { | 108 while (true) { |
| 108 std::string header_line = ShiftLine(); | 109 std::string header_line = ShiftLine(); |
| 109 if (header_line.empty()) | 110 if (header_line.empty()) |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 return METHOD_DELETE; | 194 return METHOD_DELETE; |
| 194 } else if (token == "patch") { | 195 } else if (token == "patch") { |
| 195 return METHOD_PATCH; | 196 return METHOD_PATCH; |
| 196 } | 197 } |
| 197 NOTREACHED() << "Method not implemented: " << token; | 198 NOTREACHED() << "Method not implemented: " << token; |
| 198 return METHOD_UNKNOWN; | 199 return METHOD_UNKNOWN; |
| 199 } | 200 } |
| 200 | 201 |
| 201 } // namespace test_server | 202 } // namespace test_server |
| 202 } // namespace net | 203 } // namespace net |
| OLD | NEW |