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 #include <utility> |
8 | 9 |
9 #include "base/logging.h" | 10 #include "base/logging.h" |
10 #include "base/strings/string_util.h" | |
11 #include "base/strings/string_number_conversions.h" | 11 #include "base/strings/string_number_conversions.h" |
12 #include "base/strings/string_split.h" | 12 #include "base/strings/string_split.h" |
| 13 #include "base/strings/string_util.h" |
13 #include "net/http/http_chunked_decoder.h" | 14 #include "net/http/http_chunked_decoder.h" |
14 #include "url/gurl.h" | 15 #include "url/gurl.h" |
15 | 16 |
16 namespace net { | 17 namespace net { |
17 namespace test_server { | 18 namespace test_server { |
18 | 19 |
19 namespace { | 20 namespace { |
20 | 21 |
21 size_t kRequestSizeLimit = 64 * 1024 * 1024; // 64 mb. | 22 size_t kRequestSizeLimit = 64 * 1024 * 1024; // 64 mb. |
22 | 23 |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 state_ = STATE_ACCEPTED; | 210 state_ = STATE_ACCEPTED; |
210 return ACCEPTED; | 211 return ACCEPTED; |
211 } | 212 } |
212 | 213 |
213 state_ = STATE_CONTENT; | 214 state_ = STATE_CONTENT; |
214 return WAITING; | 215 return WAITING; |
215 } | 216 } |
216 | 217 |
217 scoped_ptr<HttpRequest> HttpRequestParser::GetRequest() { | 218 scoped_ptr<HttpRequest> HttpRequestParser::GetRequest() { |
218 DCHECK_EQ(STATE_ACCEPTED, state_); | 219 DCHECK_EQ(STATE_ACCEPTED, state_); |
219 scoped_ptr<HttpRequest> result = http_request_.Pass(); | 220 scoped_ptr<HttpRequest> result = std::move(http_request_); |
220 | 221 |
221 // Prepare for parsing a new request. | 222 // Prepare for parsing a new request. |
222 state_ = STATE_HEADERS; | 223 state_ = STATE_HEADERS; |
223 http_request_.reset(new HttpRequest()); | 224 http_request_.reset(new HttpRequest()); |
224 buffer_.clear(); | 225 buffer_.clear(); |
225 buffer_position_ = 0; | 226 buffer_position_ = 0; |
226 declared_content_length_ = 0; | 227 declared_content_length_ = 0; |
227 | 228 |
228 return result.Pass(); | 229 return result; |
229 } | 230 } |
230 | 231 |
231 HttpMethod HttpRequestParser::GetMethodType(const std::string& token) const { | 232 HttpMethod HttpRequestParser::GetMethodType(const std::string& token) const { |
232 if (token == "get") { | 233 if (token == "get") { |
233 return METHOD_GET; | 234 return METHOD_GET; |
234 } else if (token == "head") { | 235 } else if (token == "head") { |
235 return METHOD_HEAD; | 236 return METHOD_HEAD; |
236 } else if (token == "post") { | 237 } else if (token == "post") { |
237 return METHOD_POST; | 238 return METHOD_POST; |
238 } else if (token == "put") { | 239 } else if (token == "put") { |
239 return METHOD_PUT; | 240 return METHOD_PUT; |
240 } else if (token == "delete") { | 241 } else if (token == "delete") { |
241 return METHOD_DELETE; | 242 return METHOD_DELETE; |
242 } else if (token == "patch") { | 243 } else if (token == "patch") { |
243 return METHOD_PATCH; | 244 return METHOD_PATCH; |
244 } else if (token == "connect") { | 245 } else if (token == "connect") { |
245 return METHOD_CONNECT; | 246 return METHOD_CONNECT; |
246 } | 247 } |
247 LOG(WARNING) << "Method not implemented: " << token; | 248 LOG(WARNING) << "Method not implemented: " << token; |
248 return METHOD_GET; | 249 return METHOD_GET; |
249 } | 250 } |
250 | 251 |
251 } // namespace test_server | 252 } // namespace test_server |
252 } // namespace net | 253 } // namespace net |
OLD | NEW |