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 #ifndef NET_TEST_EMBEDDED_TEST_SERVER_HTTP_REQUEST_H_ | 5 #ifndef NET_TEST_EMBEDDED_TEST_SERVER_HTTP_REQUEST_H_ |
6 #define NET_TEST_EMBEDDED_TEST_SERVER_HTTP_REQUEST_H_ | 6 #define NET_TEST_EMBEDDED_TEST_SERVER_HTTP_REQUEST_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "base/strings/string_piece.h" | 13 #include "base/strings/string_piece.h" |
14 #include "net/http/http_chunked_decoder.h" | |
mmenke
2015/02/12 15:34:30
Should forward declare this and include the header
xunjieli
2015/02/12 15:58:40
Done.
| |
14 | 15 |
15 namespace net { | 16 namespace net { |
16 namespace test_server { | 17 namespace test_server { |
17 | 18 |
18 // Methods of HTTP requests supported by the test HTTP server. | 19 // Methods of HTTP requests supported by the test HTTP server. |
19 enum HttpMethod { | 20 enum HttpMethod { |
20 METHOD_UNKNOWN, | 21 METHOD_UNKNOWN, |
21 METHOD_GET, | 22 METHOD_GET, |
22 METHOD_HEAD, | 23 METHOD_HEAD, |
23 METHOD_POST, | 24 METHOD_POST, |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
86 scoped_ptr<HttpRequest> GetRequest(); | 87 scoped_ptr<HttpRequest> GetRequest(); |
87 | 88 |
88 private: | 89 private: |
89 HttpMethod GetMethodType(const std::string& token) const; | 90 HttpMethod GetMethodType(const std::string& token) const; |
90 | 91 |
91 // Parses headers and returns ACCEPTED if whole request was parsed. Otherwise | 92 // Parses headers and returns ACCEPTED if whole request was parsed. Otherwise |
92 // returns WAITING. | 93 // returns WAITING. |
93 ParseResult ParseHeaders(); | 94 ParseResult ParseHeaders(); |
94 | 95 |
95 // Parses request's content data and returns ACCEPTED if all of it have been | 96 // Parses request's content data and returns ACCEPTED if all of it have been |
96 // processed. Chunked Transfer Encoding *is not* supported. | 97 // processed. Chunked Transfer Encoding is supported. |
97 ParseResult ParseContent(); | 98 ParseResult ParseContent(); |
98 | 99 |
99 // Fetches the next line from the buffer. Result does not contain \r\n. | 100 // Fetches the next line from the buffer. Result does not contain \r\n. |
100 // Returns an empty string for an empty line. It will assert if there is | 101 // Returns an empty string for an empty line. It will assert if there is |
101 // no line available. | 102 // no line available. |
102 std::string ShiftLine(); | 103 std::string ShiftLine(); |
103 | 104 |
104 scoped_ptr<HttpRequest> http_request_; | 105 scoped_ptr<HttpRequest> http_request_; |
105 std::string buffer_; | 106 std::string buffer_; |
106 size_t buffer_position_; // Current position in the internal buffer. | 107 size_t buffer_position_; // Current position in the internal buffer. |
107 State state_; | 108 State state_; |
108 // Content length of the request currently being parsed. | 109 // Content length of the request currently being parsed. |
109 size_t declared_content_length_; | 110 size_t declared_content_length_; |
110 | 111 |
112 scoped_ptr<net::HttpChunkedDecoder> chunked_decoder_; | |
113 | |
111 DISALLOW_COPY_AND_ASSIGN(HttpRequestParser); | 114 DISALLOW_COPY_AND_ASSIGN(HttpRequestParser); |
112 }; | 115 }; |
113 | 116 |
114 } // namespace test_server | 117 } // namespace test_server |
115 } // namespace net | 118 } // namespace net |
116 | 119 |
117 #endif // NET_TEST_EMBEDDED_TEST_SERVER_HTTP_REQUEST_H_ | 120 #endif // NET_TEST_EMBEDDED_TEST_SERVER_HTTP_REQUEST_H_ |
OLD | NEW |