| 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/http/http_stream_parser.h" | 5 #include "net/http/http_stream_parser.h" |
| 6 | 6 |
| 7 #include "base/file_path.h" | 7 #include "base/file_path.h" |
| 8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
| 9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "base/scoped_temp_dir.h" | 10 #include "base/scoped_temp_dir.h" |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 }; | 184 }; |
| 185 | 185 |
| 186 // The size of the response body, as reflected in the Content-Length of the | 186 // The size of the response body, as reflected in the Content-Length of the |
| 187 // MockRead below. | 187 // MockRead below. |
| 188 static const int kBodySize = 8; | 188 static const int kBodySize = 8; |
| 189 | 189 |
| 190 MockRead reads[] = { | 190 MockRead reads[] = { |
| 191 MockRead(ASYNC, 5, "HTTP/1.1 200 OK\r\n"), | 191 MockRead(ASYNC, 5, "HTTP/1.1 200 OK\r\n"), |
| 192 MockRead(ASYNC, 6, "Content-Length: 8\r\n\r\n"), | 192 MockRead(ASYNC, 6, "Content-Length: 8\r\n\r\n"), |
| 193 MockRead(ASYNC, 7, "one.html"), | 193 MockRead(ASYNC, 7, "one.html"), |
| 194 MockRead(SYNCHRONOUS, 8, 0), // EOF | 194 MockRead(SYNCHRONOUS, 0, 8), // EOF |
| 195 }; | 195 }; |
| 196 | 196 |
| 197 DeterministicSocketData data(reads, arraysize(reads), | 197 DeterministicSocketData data(reads, arraysize(reads), |
| 198 writes, arraysize(writes)); | 198 writes, arraysize(writes)); |
| 199 data.set_connect_data(MockConnect(SYNCHRONOUS, OK)); | 199 data.set_connect_data(MockConnect(SYNCHRONOUS, OK)); |
| 200 | 200 |
| 201 scoped_ptr<DeterministicMockTCPClientSocket> transport( | 201 scoped_ptr<DeterministicMockTCPClientSocket> transport( |
| 202 new DeterministicMockTCPClientSocket(NULL, &data)); | 202 new DeterministicMockTCPClientSocket(NULL, &data)); |
| 203 data.set_socket(transport->AsWeakPtr()); | 203 data.set_socket(transport->AsWeakPtr()); |
| 204 | 204 |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 296 rv = parser.ReadResponseBody(body_buffer, kBodySize, callback.callback()); | 296 rv = parser.ReadResponseBody(body_buffer, kBodySize, callback.callback()); |
| 297 ASSERT_EQ(ERR_IO_PENDING, rv); | 297 ASSERT_EQ(ERR_IO_PENDING, rv); |
| 298 data.RunFor(1); | 298 data.RunFor(1); |
| 299 | 299 |
| 300 ASSERT_TRUE(callback.have_result()); | 300 ASSERT_TRUE(callback.have_result()); |
| 301 rv = callback.WaitForResult(); | 301 rv = callback.WaitForResult(); |
| 302 ASSERT_EQ(kBodySize, rv); | 302 ASSERT_EQ(kBodySize, rv); |
| 303 } | 303 } |
| 304 | 304 |
| 305 } // namespace net | 305 } // namespace net |
| OLD | NEW |