OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "net/test/embedded_test_server/http_response.h" | 5 #include "net/test/embedded_test_server/http_response.h" |
6 | 6 |
7 #include "base/format_macros.h" | 7 #include "base/format_macros.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/stringprintf.h" | 9 #include "base/stringprintf.h" |
10 | 10 |
11 namespace net { | 11 namespace net { |
12 namespace test_server { | 12 namespace test_server { |
13 | 13 |
14 HttpResponse::HttpResponse() : code_(SUCCESS) { | |
15 } | |
16 | |
17 HttpResponse::~HttpResponse() { | 14 HttpResponse::~HttpResponse() { |
18 } | 15 } |
19 | 16 |
20 std::string HttpResponse::ToResponseString() const { | 17 BasicHttpResponse::BasicHttpResponse() : code_(SUCCESS) { |
| 18 } |
| 19 |
| 20 BasicHttpResponse::~BasicHttpResponse() { |
| 21 } |
| 22 |
| 23 std::string BasicHttpResponse::ToResponseString() const { |
21 // Response line with headers. | 24 // Response line with headers. |
22 std::string response_builder; | 25 std::string response_builder; |
23 | 26 |
24 // TODO(mtomasz): For http/1.0 requests, send http/1.0. | 27 // TODO(mtomasz): For http/1.0 requests, send http/1.0. |
25 // TODO(mtomasz): For different codes, send a corrent string instead of OK. | 28 // TODO(mtomasz): For different codes, send a corrent string instead of OK. |
26 base::StringAppendF(&response_builder, "HTTP/1.1 %d OK\r\n", code_); | 29 base::StringAppendF(&response_builder, "HTTP/1.1 %d OK\r\n", code_); |
27 base::StringAppendF(&response_builder, "Connection: closed\r\n"); | 30 base::StringAppendF(&response_builder, "Connection: closed\r\n"); |
28 base::StringAppendF(&response_builder, | 31 base::StringAppendF(&response_builder, |
29 "Content-Length: %"PRIuS"\r\n", | 32 "Content-Length: %"PRIuS"\r\n", |
30 content_.size()); | 33 content_.size()); |
(...skipping 14 matching lines...) Expand all Loading... |
45 header_name.c_str(), | 48 header_name.c_str(), |
46 header_value.c_str()); | 49 header_value.c_str()); |
47 } | 50 } |
48 base::StringAppendF(&response_builder, "\r\n"); | 51 base::StringAppendF(&response_builder, "\r\n"); |
49 | 52 |
50 return response_builder + content_; | 53 return response_builder + content_; |
51 } | 54 } |
52 | 55 |
53 } // namespace test_server | 56 } // namespace test_server |
54 } // namespace net | 57 } // namespace net |
OLD | NEW |