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