OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "chrome/test/chromedriver/server/http_response.h" | 5 #include "chrome/test/chromedriver/server/http_response.h" |
6 | 6 |
7 #include "base/format_macros.h" | 7 #include "base/format_macros.h" |
8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
10 | 10 |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 status_, GetReasonPhrase().c_str()); | 115 status_, GetReasonPhrase().c_str()); |
116 | 116 |
117 typedef HttpResponse::HeaderMap::const_iterator HeaderIter; | 117 typedef HttpResponse::HeaderMap::const_iterator HeaderIter; |
118 for (HeaderIter header = headers_.begin(); header != headers_.end(); | 118 for (HeaderIter header = headers_.begin(); header != headers_.end(); |
119 ++header) { | 119 ++header) { |
120 *data += header->first + ":" + header->second + "\r\n"; | 120 *data += header->first + ":" + header->second + "\r\n"; |
121 } | 121 } |
122 std::string length; | 122 std::string length; |
123 if (!GetHeader(kContentLengthHeader, &length)) { | 123 if (!GetHeader(kContentLengthHeader, &length)) { |
124 *data += base::StringPrintf( | 124 *data += base::StringPrintf( |
125 "%s:%"PRIuS"\r\n", | 125 "%s:%" PRIuS "\r\n", |
126 kContentLengthHeader, body_.length()); | 126 kContentLengthHeader, body_.length()); |
127 } | 127 } |
128 *data += "\r\n"; | 128 *data += "\r\n"; |
129 | 129 |
130 if (body_.length()) | 130 if (body_.length()) |
131 *data += body_; | 131 *data += body_; |
132 } | 132 } |
133 | 133 |
134 int HttpResponse::status() const { | 134 int HttpResponse::status() const { |
135 return status_; | 135 return status_; |
136 } | 136 } |
137 | 137 |
138 void HttpResponse::set_status(int status) { | 138 void HttpResponse::set_status(int status) { |
139 status_ = status; | 139 status_ = status; |
140 } | 140 } |
141 | 141 |
142 const std::string& HttpResponse::body() const { | 142 const std::string& HttpResponse::body() const { |
143 return body_; | 143 return body_; |
144 } | 144 } |
145 | 145 |
146 void HttpResponse::set_body(const std::string& body) { | 146 void HttpResponse::set_body(const std::string& body) { |
147 body_ = body; | 147 body_ = body; |
148 } | 148 } |
149 | 149 |
150 void HttpResponse::UpdateHeader(const std::string& name, | 150 void HttpResponse::UpdateHeader(const std::string& name, |
151 const std::string& new_value) { | 151 const std::string& new_value) { |
152 RemoveHeader(name); | 152 RemoveHeader(name); |
153 AddHeader(name, new_value); | 153 AddHeader(name, new_value); |
154 } | 154 } |
OLD | NEW |