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

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

Issue 2694923006: [Embedded Test Server] Enable handler HandleEchoHeader echoing multiple headers (Closed)
Patch Set: 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..85ed95b39c948b91c99c9c6f09140cbc78ac241f 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,22 @@ std::unique_ptr<HttpResponse> HandleEchoHeader(const std::string& url,
std::unique_ptr<BasicHttpResponse> http_response(new BasicHttpResponse);
GURL request_url = request.GetURL();
+ std::string content;
if (request_url.has_query()) {
- std::string header_name = request_url.query();
- http_response->AddCustomHeader("Vary", header_name);
- if (request.headers.find(header_name) != request.headers.end())
- http_response->set_content(request.headers.at(header_name));
- else
- http_response->set_content("None");
+ std::vector<std::string> header_names = base::SplitString(
svaldez 2017/02/14 20:23:43 std::string vary; std::string content; RequestQuer
shenghuazhang 2017/02/15 01:14:03 Done.
+ request_url.query(), "&", base::KEEP_WHITESPACE, base::SPLIT_WANT_ALL);
+ for (const auto& header_name : header_names) {
+ http_response->AddCustomHeader("Vary", header_name);
+ if (!content.empty())
+ content += "\n";
shenghuazhang 2017/02/14 20:06:42 I used "\n" to separate the header values here. Bu
+ if (request.headers.find(header_name) != request.headers.end())
+ content += request.headers.at(header_name);
+ else
+ content += "None";
+ }
}
+ 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