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

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

Issue 16268017: GTTF: convert some tests in chrome to use EmbeddedTestServer patch nr 1 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 6 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
Index: net/test/embedded_test_server/http_response.cc
diff --git a/net/test/embedded_test_server/http_response.cc b/net/test/embedded_test_server/http_response.cc
index 759c0567bcc5c9ff989b3d0370a338b1b30a9ead..64bf3ecf78daa04eef33581109c23c209ab5dccf 100644
--- a/net/test/embedded_test_server/http_response.cc
+++ b/net/test/embedded_test_server/http_response.cc
@@ -7,6 +7,7 @@
#include "base/format_macros.h"
#include "base/logging.h"
#include "base/strings/stringprintf.h"
+#include "net/http/http_status_code.h"
namespace net {
namespace test_server {
@@ -14,7 +15,7 @@ namespace test_server {
HttpResponse::~HttpResponse() {
}
-BasicHttpResponse::BasicHttpResponse() : code_(SUCCESS) {
+BasicHttpResponse::BasicHttpResponse() : code_(HTTP_OK) {
}
BasicHttpResponse::~BasicHttpResponse() {
@@ -24,23 +25,23 @@ std::string BasicHttpResponse::ToResponseString() const {
// Response line with headers.
std::string response_builder;
+ std::string http_reason_phrase(GetHttpReasonPhrase(code_));
+
// TODO(mtomasz): For http/1.0 requests, send http/1.0.
- // TODO(mtomasz): For different codes, send a corrent string instead of OK.
- base::StringAppendF(&response_builder, "HTTP/1.1 %d OK\r\n", code_);
- base::StringAppendF(&response_builder, "Connection: closed\r\n");
+ base::StringAppendF(&response_builder,
+ "HTTP/1.1 %d %s\r\n",
+ code_,
+ http_reason_phrase.c_str());
+ base::StringAppendF(&response_builder, "Connection: close\r\n");
base::StringAppendF(&response_builder,
"Content-Length: %"PRIuS"\r\n",
content_.size());
base::StringAppendF(&response_builder,
"Content-Type: %s\r\n",
content_type_.c_str());
- for (std::map<std::string, std::string>::const_iterator it =
- custom_headers_.begin();
- it != custom_headers_.end();
- ++it) {
- // Multi-line header value support.
- const std::string& header_name = it->first;
- const std::string& header_value = it->second;
+ for (size_t i = 0; i < custom_headers_.size(); ++i) {
+ const std::string& header_name = custom_headers_[i].first;
+ const std::string& header_value = custom_headers_[i].second;
DCHECK(header_value.find_first_of("\n\r") == std::string::npos) <<
"Malformed header value.";
base::StringAppendF(&response_builder,
« no previous file with comments | « net/test/embedded_test_server/http_response.h ('k') | net/test/embedded_test_server/http_response_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698