| 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 #include "ios/web/public/test/response_providers/response_provider.h" | 5 #include "ios/web/public/test/response_providers/response_provider.h" |
| 6 | 6 |
| 7 #include "base/strings/stringprintf.h" | 7 #include "base/strings/stringprintf.h" |
| 8 #include "net/http/http_response_headers.h" | 8 #include "net/http/http_response_headers.h" |
| 9 | 9 |
| 10 namespace web { | 10 namespace web { |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 return GetResponseHeaders(content_type, net::HTTP_OK); | 43 return GetResponseHeaders(content_type, net::HTTP_OK); |
| 44 } | 44 } |
| 45 | 45 |
| 46 // static | 46 // static |
| 47 scoped_refptr<net::HttpResponseHeaders> | 47 scoped_refptr<net::HttpResponseHeaders> |
| 48 ResponseProvider::GetDefaultResponseHeaders() { | 48 ResponseProvider::GetDefaultResponseHeaders() { |
| 49 return GetResponseHeaders("text/html", net::HTTP_OK); | 49 return GetResponseHeaders("text/html", net::HTTP_OK); |
| 50 } | 50 } |
| 51 | 51 |
| 52 // static | 52 // static |
| 53 scoped_refptr<net::HttpResponseHeaders> | 53 std::map<GURL, scoped_refptr<net::HttpResponseHeaders>> |
| 54 ResponseProvider::GetDefaultResponseHeaders(const std::string& cookie) { | 54 ResponseProvider::GetDefaultResponseHeaders( |
| 55 scoped_refptr<net::HttpResponseHeaders> result = GetDefaultResponseHeaders(); | 55 const std::map<GURL, std::pair<std::string, std::string>>& responses) { |
| 56 result->AddCookie(cookie); | 56 std::map<GURL, scoped_refptr<net::HttpResponseHeaders>> headers; |
| 57 return result; | 57 for (const auto& pair : responses) { |
| 58 std::string cookie = pair.second.first; |
| 59 scoped_refptr<net::HttpResponseHeaders> result = |
| 60 GetDefaultResponseHeaders(); |
| 61 if (!cookie.empty()) { |
| 62 result->AddCookie(cookie); |
| 63 } |
| 64 headers.insert(std::make_pair(pair.first, result)); |
| 65 } |
| 66 return headers; |
| 58 } | 67 } |
| 59 | 68 |
| 60 // static | 69 // static |
| 61 scoped_refptr<net::HttpResponseHeaders> | 70 scoped_refptr<net::HttpResponseHeaders> |
| 62 ResponseProvider::GetRedirectResponseHeaders( | 71 ResponseProvider::GetRedirectResponseHeaders( |
| 63 const std::string& destination, | 72 const std::string& destination, |
| 64 const net::HttpStatusCode& http_status) { | 73 const net::HttpStatusCode& http_status) { |
| 65 scoped_refptr<net::HttpResponseHeaders> headers( | 74 scoped_refptr<net::HttpResponseHeaders> headers( |
| 66 GetResponseHeaders("text/html", http_status)); | 75 GetResponseHeaders("text/html", http_status)); |
| 67 headers->AddHeader("Location: " + destination); | 76 headers->AddHeader("Location: " + destination); |
| 68 return headers; | 77 return headers; |
| 69 } | 78 } |
| 70 | 79 |
| 71 } // namespace web | 80 } // namespace web |
| OLD | NEW |