| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 IOS_WEB_PUBLIC_TEST_RESPONSE_PROVIDERS_RESPONSE_PROVIDER_H_ | 5 #ifndef IOS_WEB_PUBLIC_TEST_RESPONSE_PROVIDERS_RESPONSE_PROVIDER_H_ |
| 6 #define IOS_WEB_PUBLIC_TEST_RESPONSE_PROVIDERS_RESPONSE_PROVIDER_H_ | 6 #define IOS_WEB_PUBLIC_TEST_RESPONSE_PROVIDERS_RESPONSE_PROVIDER_H_ |
| 7 | 7 |
| 8 #include <map> |
| 8 #include <string> | 9 #include <string> |
| 9 | 10 |
| 10 #include "base/macros.h" | 11 #include "base/macros.h" |
| 11 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
| 12 #include "net/http/http_request_headers.h" | 13 #include "net/http/http_request_headers.h" |
| 13 #include "net/http/http_response_headers.h" | 14 #include "net/http/http_response_headers.h" |
| 14 #include "net/http/http_status_code.h" | 15 #include "net/http/http_status_code.h" |
| 15 #include "url/gurl.h" | 16 #include "url/gurl.h" |
| 16 | 17 |
| 17 @class GCDWebServerResponse; | 18 @class GCDWebServerResponse; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 46 virtual bool CanHandleRequest(const Request& request) = 0; | 47 virtual bool CanHandleRequest(const Request& request) = 0; |
| 47 | 48 |
| 48 // Returns the GCDWebServerResponse as a reply to the request. Will only be | 49 // Returns the GCDWebServerResponse as a reply to the request. Will only be |
| 49 // called if the provider can handle the request. | 50 // called if the provider can handle the request. |
| 50 virtual GCDWebServerResponse* GetGCDWebServerResponse( | 51 virtual GCDWebServerResponse* GetGCDWebServerResponse( |
| 51 const Request& request) = 0; | 52 const Request& request) = 0; |
| 52 | 53 |
| 53 // Gets default response headers with a text/html content type and a 200 | 54 // Gets default response headers with a text/html content type and a 200 |
| 54 // response code. | 55 // response code. |
| 55 static scoped_refptr<net::HttpResponseHeaders> GetDefaultResponseHeaders(); | 56 static scoped_refptr<net::HttpResponseHeaders> GetDefaultResponseHeaders(); |
| 56 // Gets default response headers with a text/html content type and a 200 | 57 // Gets a map of response headers with a text/html content type, a 200 |
| 57 // response code. | 58 // response code and Set-Cookie in headers. |
| 58 static scoped_refptr<net::HttpResponseHeaders> GetDefaultResponseHeaders( | 59 static std::map<GURL, scoped_refptr<net::HttpResponseHeaders>> |
| 59 const std::string& cookie); | 60 GetDefaultResponseHeaders( |
| 61 const std::map<GURL, std::pair<std::string, std::string>>& responses); |
| 60 // Gets configurable response headers with a provided content type and a | 62 // Gets configurable response headers with a provided content type and a |
| 61 // 200 response code. | 63 // 200 response code. |
| 62 static scoped_refptr<net::HttpResponseHeaders> GetResponseHeaders( | 64 static scoped_refptr<net::HttpResponseHeaders> GetResponseHeaders( |
| 63 const std::string& content_type); | 65 const std::string& content_type); |
| 64 // Gets configurable response headers with a provided content type and | 66 // Gets configurable response headers with a provided content type and |
| 65 // response code. | 67 // response code. |
| 66 static scoped_refptr<net::HttpResponseHeaders> GetResponseHeaders( | 68 static scoped_refptr<net::HttpResponseHeaders> GetResponseHeaders( |
| 67 const std::string& content_type, | 69 const std::string& content_type, |
| 68 net::HttpStatusCode response_code); | 70 net::HttpStatusCode response_code); |
| 69 // Gets configurable response based on |http_status| headers for redirecting | 71 // Gets configurable response based on |http_status| headers for redirecting |
| 70 // to |destination|. | 72 // to |destination|. |
| 71 static scoped_refptr<net::HttpResponseHeaders> GetRedirectResponseHeaders( | 73 static scoped_refptr<net::HttpResponseHeaders> GetRedirectResponseHeaders( |
| 72 const std::string& destination, | 74 const std::string& destination, |
| 73 const net::HttpStatusCode& http_status); | 75 const net::HttpStatusCode& http_status); |
| 74 | 76 |
| 75 ResponseProvider(); | 77 ResponseProvider(); |
| 76 virtual ~ResponseProvider() {}; | 78 virtual ~ResponseProvider() {}; |
| 77 private: | 79 private: |
| 78 DISALLOW_COPY_AND_ASSIGN(ResponseProvider); | 80 DISALLOW_COPY_AND_ASSIGN(ResponseProvider); |
| 79 }; | 81 }; |
| 80 | 82 |
| 81 } // namspace web | 83 } // namspace web |
| 82 | 84 |
| 83 #endif // IOS_WEB_PUBLIC_TEST_RESPONSE_PROVIDERS_RESPONSE_PROVIDER_H_ | 85 #endif // IOS_WEB_PUBLIC_TEST_RESPONSE_PROVIDERS_RESPONSE_PROVIDER_H_ |
| OLD | NEW |