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

Unified Diff: net/test/embedded_test_server/default_handlers.cc

Issue 2694923006: [Embedded Test Server] Enable handler HandleEchoHeader echoing multiple headers (Closed)
Patch Set: svaldez comment Created 3 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/test/embedded_test_server/default_handlers.cc
diff --git a/net/test/embedded_test_server/default_handlers.cc b/net/test/embedded_test_server/default_handlers.cc
index 16c2487742e2520e2f0d980e06eb8e1965dddc26..ce337ba4e72ca37f9875f7a2305af0bd35a5a40b 100644
--- a/net/test/embedded_test_server/default_handlers.cc
+++ b/net/test/embedded_test_server/default_handlers.cc
@@ -70,7 +70,7 @@ std::unique_ptr<HttpResponse> HandleCacheTime(const HttpRequest& request) {
return std::move(http_response);
}
-// /echoheader | /echoheadercache
+// /echoheader?HEADERS | /echoheadercache?HEADERS
// Responds with the headers echoed in the message body.
// echoheader does not cache the results, while echoheadercache does.
std::unique_ptr<HttpResponse> HandleEchoHeader(const std::string& url,
@@ -82,15 +82,24 @@ std::unique_ptr<HttpResponse> HandleEchoHeader(const std::string& url,
std::unique_ptr<BasicHttpResponse> http_response(new BasicHttpResponse);
GURL request_url = request.GetURL();
- if (request_url.has_query()) {
- std::string header_name = request_url.query();
- http_response->AddCustomHeader("Vary", header_name);
+ std::string vary;
+ std::string content;
+ RequestQuery headers = ParseQuery(request_url);
+ for (const auto& header : headers) {
+ std::string header_name = header.first;
+ std::string header_value = "None";
if (request.headers.find(header_name) != request.headers.end())
- http_response->set_content(request.headers.at(header_name));
- else
- http_response->set_content("None");
+ header_value = request.headers.at(header_name);
+ if (!vary.empty())
+ vary += ",";
+ vary += header_name;
+ if (!content.empty())
+ content += "\n";
+ content += header_value;
}
+ http_response->AddCustomHeader("Vary", vary);
+ http_response->set_content(content);
http_response->set_content_type("text/plain");
http_response->AddCustomHeader("Cache-Control", cache_control);
return std::move(http_response);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698