| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/webdriver/http_response.h" | 5 #include "chrome/test/webdriver/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 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 status_, GetReasonPhrase().c_str()); | 117 status_, GetReasonPhrase().c_str()); |
| 118 | 118 |
| 119 typedef HttpResponse::HeaderMap::const_iterator HeaderIter; | 119 typedef HttpResponse::HeaderMap::const_iterator HeaderIter; |
| 120 for (HeaderIter header = headers_.begin(); header != headers_.end(); | 120 for (HeaderIter header = headers_.begin(); header != headers_.end(); |
| 121 ++header) { | 121 ++header) { |
| 122 *data += header->first + ":" + header->second + "\r\n"; | 122 *data += header->first + ":" + header->second + "\r\n"; |
| 123 } | 123 } |
| 124 std::string length; | 124 std::string length; |
| 125 if (!GetHeader(kContentLengthHeader, &length)) { | 125 if (!GetHeader(kContentLengthHeader, &length)) { |
| 126 *data += base::StringPrintf( | 126 *data += base::StringPrintf( |
| 127 "%s:%"PRIuS"\r\n", | 127 "%s:%" PRIuS "\r\n", kContentLengthHeader, body_.length()); |
| 128 kContentLengthHeader, body_.length()); | |
| 129 } | 128 } |
| 130 *data += "\r\n"; | 129 *data += "\r\n"; |
| 131 | 130 |
| 132 if (body_.length()) | 131 if (body_.length()) |
| 133 *data += body_; | 132 *data += body_; |
| 134 } | 133 } |
| 135 | 134 |
| 136 int HttpResponse::status() const { | 135 int HttpResponse::status() const { |
| 137 return status_; | 136 return status_; |
| 138 } | 137 } |
| (...skipping 10 matching lines...) Expand all Loading... |
| 149 body_ = body; | 148 body_ = body; |
| 150 } | 149 } |
| 151 | 150 |
| 152 void HttpResponse::UpdateHeader(const std::string& name, | 151 void HttpResponse::UpdateHeader(const std::string& name, |
| 153 const std::string& new_value) { | 152 const std::string& new_value) { |
| 154 RemoveHeader(name); | 153 RemoveHeader(name); |
| 155 AddHeader(name, new_value); | 154 AddHeader(name, new_value); |
| 156 } | 155 } |
| 157 | 156 |
| 158 } // namespace webdriver | 157 } // namespace webdriver |
| OLD | NEW |