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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 // Check if the all request headers are available. | 81 // Check if the all request headers are available. |
82 if (buffer_.find("\r\n\r\n", buffer_position_) == std::string::npos) | 82 if (buffer_.find("\r\n\r\n", buffer_position_) == std::string::npos) |
83 return WAITING; | 83 return WAITING; |
84 | 84 |
85 // Parse request's the first header line. | 85 // Parse request's the first header line. |
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; | 91 std::vector<std::string> header_line_tokens = base::SplitString( |
92 base::SplitString(header_line, ' ', &header_line_tokens); | 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 = GetMethodType(base::StringToLowerASCII( |
97 header_line_tokens[0])); | 97 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. |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 return METHOD_DELETE; | 225 return METHOD_DELETE; |
226 } else if (token == "patch") { | 226 } else if (token == "patch") { |
227 return METHOD_PATCH; | 227 return METHOD_PATCH; |
228 } | 228 } |
229 NOTREACHED() << "Method not implemented: " << token; | 229 NOTREACHED() << "Method not implemented: " << token; |
230 return METHOD_UNKNOWN; | 230 return METHOD_UNKNOWN; |
231 } | 231 } |
232 | 232 |
233 } // namespace test_server | 233 } // namespace test_server |
234 } // namespace net | 234 } // namespace net |
OLD | NEW |