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/net/adb_client_socket.h" | 5 #include "chrome/test/chromedriver/net/adb_client_socket.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
10 #include "base/strings/string_split.h" | 10 #include "base/strings/string_split.h" |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 | 178 |
179 response_ += std::string(response_buffer->data(), result); | 179 response_ += std::string(response_buffer->data(), result); |
180 int expected_length = 0; | 180 int expected_length = 0; |
181 if (bytes_total < 0) { | 181 if (bytes_total < 0) { |
182 size_t content_pos = response_.find("Content-Length:"); | 182 size_t content_pos = response_.find("Content-Length:"); |
183 if (content_pos != std::string::npos) { | 183 if (content_pos != std::string::npos) { |
184 size_t endline_pos = response_.find("\n", content_pos); | 184 size_t endline_pos = response_.find("\n", content_pos); |
185 if (endline_pos != std::string::npos) { | 185 if (endline_pos != std::string::npos) { |
186 std::string len = response_.substr(content_pos + 15, | 186 std::string len = response_.substr(content_pos + 15, |
187 endline_pos - content_pos - 15); | 187 endline_pos - content_pos - 15); |
188 base::TrimWhitespace(len, base::TRIM_ALL, &len); | 188 base::TrimWhitespaceASCII(len, base::TRIM_ALL, &len); |
189 if (!base::StringToInt(len, &expected_length)) { | 189 if (!base::StringToInt(len, &expected_length)) { |
190 CheckNetResultOrDie(net::ERR_FAILED); | 190 CheckNetResultOrDie(net::ERR_FAILED); |
191 return; | 191 return; |
192 } | 192 } |
193 } | 193 } |
194 } | 194 } |
195 | 195 |
196 body_pos_ = response_.find("\r\n\r\n"); | 196 body_pos_ = response_.find("\r\n\r\n"); |
197 if (body_pos_ != std::string::npos) { | 197 if (body_pos_ != std::string::npos) { |
198 body_pos_ += 4; | 198 body_pos_ += 4; |
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
535 base::Unretained(this), | 535 base::Unretained(this), |
536 callback, | 536 callback, |
537 new_response, | 537 new_response, |
538 response_buffer, | 538 response_buffer, |
539 bytes_left)); | 539 bytes_left)); |
540 if (result > 0) | 540 if (result > 0) |
541 OnResponseData(callback, new_response, response_buffer, bytes_left, result); | 541 OnResponseData(callback, new_response, response_buffer, bytes_left, result); |
542 else if (result != net::ERR_IO_PENDING) | 542 else if (result != net::ERR_IO_PENDING) |
543 callback.Run(net::OK, new_response); | 543 callback.Run(net::OK, new_response); |
544 } | 544 } |
OLD | NEW |