| 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 "url/gurl.h" | |
| 15 | 14 |
| 16 namespace net { | 15 namespace net { |
| 17 | 16 |
| 18 class HttpChunkedDecoder; | 17 class HttpChunkedDecoder; |
| 19 | 18 |
| 20 namespace test_server { | 19 namespace test_server { |
| 21 | 20 |
| 22 // Methods of HTTP requests supported by the test HTTP server. | 21 // Methods of HTTP requests supported by the test HTTP server. |
| 23 enum HttpMethod { | 22 enum HttpMethod { |
| 24 METHOD_UNKNOWN, | 23 METHOD_UNKNOWN, |
| 25 METHOD_GET, | 24 METHOD_GET, |
| 26 METHOD_HEAD, | 25 METHOD_HEAD, |
| 27 METHOD_POST, | 26 METHOD_POST, |
| 28 METHOD_PUT, | 27 METHOD_PUT, |
| 29 METHOD_DELETE, | 28 METHOD_DELETE, |
| 30 METHOD_PATCH, | 29 METHOD_PATCH, |
| 31 METHOD_CONNECT, | |
| 32 }; | 30 }; |
| 33 | 31 |
| 34 // Represents a HTTP request. Since it can be big, use scoped_ptr to pass it | 32 // Represents a HTTP request. Since it can be big, use scoped_ptr to pass it |
| 35 // instead of copying. However, the struct is copyable so tests can save and | 33 // instead of copying. However, the struct is copyable so tests can save and |
| 36 // examine a HTTP request. | 34 // examine a HTTP request. |
| 37 struct HttpRequest { | 35 struct HttpRequest { |
| 38 HttpRequest(); | 36 HttpRequest(); |
| 39 ~HttpRequest(); | 37 ~HttpRequest(); |
| 40 | 38 |
| 41 // Returns a GURL as a convenience to extract the path and query strings. | |
| 42 // TODO(svaldez): Use provided URL if available. | |
| 43 GURL GetURL() const; | |
| 44 | |
| 45 std::string relative_url; // Starts with '/'. Example: "/test?query=foo" | 39 std::string relative_url; // Starts with '/'. Example: "/test?query=foo" |
| 46 HttpMethod method; | 40 HttpMethod method; |
| 47 std::string method_string; | 41 std::string method_string; |
| 48 std::string all_headers; | 42 std::string all_headers; |
| 49 std::map<std::string, std::string> headers; | 43 std::map<std::string, std::string> headers; |
| 50 std::string content; | 44 std::string content; |
| 51 bool has_content; | 45 bool has_content; |
| 52 }; | 46 }; |
| 53 | 47 |
| 54 // Parses the input data and produces a valid HttpRequest object. If there is | 48 // Parses the input data and produces a valid HttpRequest object. If there is |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 | 113 |
| 120 scoped_ptr<HttpChunkedDecoder> chunked_decoder_; | 114 scoped_ptr<HttpChunkedDecoder> chunked_decoder_; |
| 121 | 115 |
| 122 DISALLOW_COPY_AND_ASSIGN(HttpRequestParser); | 116 DISALLOW_COPY_AND_ASSIGN(HttpRequestParser); |
| 123 }; | 117 }; |
| 124 | 118 |
| 125 } // namespace test_server | 119 } // namespace test_server |
| 126 } // namespace net | 120 } // namespace net |
| 127 | 121 |
| 128 #endif // NET_TEST_EMBEDDED_TEST_SERVER_HTTP_REQUEST_H_ | 122 #endif // NET_TEST_EMBEDDED_TEST_SERVER_HTTP_REQUEST_H_ |
| OLD | NEW |