Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(228)

Side by Side Diff: ios/web/public/test/response_providers/response_provider.mm

Issue 2291393003: Add capability to simple http server to bound Set-Cookie to URLs. (Closed)
Patch Set: Update comments Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 std::pair<GURL, std::pair<std::string, std::string>>& pair :
58 responses) {
59 std::string cookie = pair.second.first;
60 scoped_refptr<net::HttpResponseHeaders> result =
61 GetDefaultResponseHeaders();
62 if (!cookie.empty()) {
63 result->AddCookie(cookie);
64 }
65 headers.insert(std::make_pair(pair.first, result));
66 }
67 return headers;
58 } 68 }
59 69
60 // static 70 // static
61 scoped_refptr<net::HttpResponseHeaders> 71 scoped_refptr<net::HttpResponseHeaders>
62 ResponseProvider::GetRedirectResponseHeaders( 72 ResponseProvider::GetRedirectResponseHeaders(
63 const std::string& destination, 73 const std::string& destination,
64 const net::HttpStatusCode& http_status) { 74 const net::HttpStatusCode& http_status) {
65 scoped_refptr<net::HttpResponseHeaders> headers( 75 scoped_refptr<net::HttpResponseHeaders> headers(
66 GetResponseHeaders("text/html", http_status)); 76 GetResponseHeaders("text/html", http_status));
67 headers->AddHeader("Location: " + destination); 77 headers->AddHeader("Location: " + destination);
68 return headers; 78 return headers;
69 } 79 }
70 80
71 } // namespace web 81 } // namespace web
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698