Chromium Code Reviews| 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/spdy/spdy_http_stream.h" | 5 #include "net/spdy/spdy_http_stream.h" |
| 6 | 6 |
| 7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
| 8 #include "base/threading/sequenced_worker_pool.h" | 8 #include "base/threading/sequenced_worker_pool.h" |
| 9 #include "crypto/ec_private_key.h" | 9 #include "crypto/ec_private_key.h" |
| 10 #include "crypto/ec_signature_creator.h" | 10 #include "crypto/ec_signature_creator.h" |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 27 OrderedSocketData* data() { return data_.get(); } | 27 OrderedSocketData* data() { return data_.get(); } |
| 28 protected: | 28 protected: |
| 29 SpdyHttpStreamSpdy3Test() {} | 29 SpdyHttpStreamSpdy3Test() {} |
| 30 | 30 |
| 31 virtual void SetUp() { | 31 virtual void SetUp() { |
| 32 SpdySession::set_default_protocol(kProtoSPDY3); | 32 SpdySession::set_default_protocol(kProtoSPDY3); |
| 33 } | 33 } |
| 34 | 34 |
| 35 virtual void TearDown() { | 35 virtual void TearDown() { |
| 36 crypto::ECSignatureCreator::SetFactoryForTesting(NULL); | 36 crypto::ECSignatureCreator::SetFactoryForTesting(NULL); |
| 37 UploadDataStream::ResetMergeChunks(); | |
| 37 MessageLoop::current()->RunAllPending(); | 38 MessageLoop::current()->RunAllPending(); |
| 38 } | 39 } |
| 39 | 40 |
| 41 void set_merge_chunks(bool merge) { | |
| 42 UploadDataStream::set_merge_chunks(merge); | |
| 43 } | |
| 44 | |
| 40 int InitSession(MockRead* reads, size_t reads_count, | 45 int InitSession(MockRead* reads, size_t reads_count, |
| 41 MockWrite* writes, size_t writes_count, | 46 MockWrite* writes, size_t writes_count, |
| 42 HostPortPair& host_port_pair) { | 47 HostPortPair& host_port_pair) { |
| 43 HostPortProxyPair pair(host_port_pair, ProxyServer::Direct()); | 48 HostPortProxyPair pair(host_port_pair, ProxyServer::Direct()); |
| 44 data_.reset(new OrderedSocketData(reads, reads_count, | 49 data_.reset(new OrderedSocketData(reads, reads_count, |
| 45 writes, writes_count)); | 50 writes, writes_count)); |
| 46 session_deps_.socket_factory->AddSocketDataProvider(data_.get()); | 51 session_deps_.socket_factory->AddSocketDataProvider(data_.get()); |
| 47 http_session_ = SpdySessionDependencies::SpdyCreateSession(&session_deps_); | 52 http_session_ = SpdySessionDependencies::SpdyCreateSession(&session_deps_); |
| 48 session_ = http_session_->spdy_session_pool()->Get(pair, BoundNetLog()); | 53 session_ = http_session_->spdy_session_pool()->Get(pair, BoundNetLog()); |
| 49 transport_params_ = new TransportSocketParams(host_port_pair, | 54 transport_params_ = new TransportSocketParams(host_port_pair, |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 119 data()->CompleteRead(); | 124 data()->CompleteRead(); |
| 120 | 125 |
| 121 // Because we abandoned the stream, we don't expect to find a session in the | 126 // Because we abandoned the stream, we don't expect to find a session in the |
| 122 // pool anymore. | 127 // pool anymore. |
| 123 EXPECT_FALSE(http_session_->spdy_session_pool()->HasSession(pair)); | 128 EXPECT_FALSE(http_session_->spdy_session_pool()->HasSession(pair)); |
| 124 EXPECT_TRUE(data()->at_read_eof()); | 129 EXPECT_TRUE(data()->at_read_eof()); |
| 125 EXPECT_TRUE(data()->at_write_eof()); | 130 EXPECT_TRUE(data()->at_write_eof()); |
| 126 } | 131 } |
| 127 | 132 |
| 128 TEST_F(SpdyHttpStreamSpdy3Test, SendChunkedPost) { | 133 TEST_F(SpdyHttpStreamSpdy3Test, SendChunkedPost) { |
| 129 UploadDataStream::set_merge_chunks(false); | 134 // Disable merging of chunks until we have a better way to unit test POST |
| 135 // requests with chunked uploads. | |
| 136 set_merge_chunks(false); | |
| 130 | 137 |
| 131 scoped_ptr<SpdyFrame> req(ConstructChunkedSpdyPost(NULL, 0)); | 138 scoped_ptr<SpdyFrame> req(ConstructChunkedSpdyPost(NULL, 0)); |
| 132 scoped_ptr<SpdyFrame> chunk1(ConstructSpdyBodyFrame(1, false)); | 139 scoped_ptr<SpdyFrame> chunk1(ConstructSpdyBodyFrame(1, false)); |
| 133 scoped_ptr<SpdyFrame> chunk2(ConstructSpdyBodyFrame(1, true)); | 140 scoped_ptr<SpdyFrame> chunk2(ConstructSpdyBodyFrame(1, true)); |
| 134 MockWrite writes[] = { | 141 MockWrite writes[] = { |
| 135 CreateMockWrite(*req.get(), 1), | 142 CreateMockWrite(*req.get(), 0), |
| 136 CreateMockWrite(*chunk1, 2), // POST upload frames | 143 CreateMockWrite(*chunk1, 1), // POST upload frames |
| 137 CreateMockWrite(*chunk2, 3), | 144 CreateMockWrite(*chunk2, 2), |
| 138 }; | 145 }; |
| 139 scoped_ptr<SpdyFrame> resp(ConstructSpdyPostSynReply(NULL, 0)); | 146 scoped_ptr<SpdyFrame> resp(ConstructSpdyPostSynReply(NULL, 0)); |
| 140 MockRead reads[] = { | 147 MockRead reads[] = { |
| 141 CreateMockRead(*resp, 4), | 148 CreateMockRead(*resp, 3), |
| 142 CreateMockRead(*chunk1, 5), | 149 CreateMockRead(*chunk1, 4), |
| 143 CreateMockRead(*chunk2, 5), | 150 CreateMockRead(*chunk2, 5), |
| 144 MockRead(SYNCHRONOUS, 0, 6) // EOF | 151 MockRead(SYNCHRONOUS, 0, 6) // EOF |
| 145 }; | 152 }; |
| 146 | 153 |
| 147 HostPortPair host_port_pair("www.google.com", 80); | 154 HostPortPair host_port_pair("www.google.com", 80); |
| 148 HostPortProxyPair pair(host_port_pair, ProxyServer::Direct()); | 155 HostPortProxyPair pair(host_port_pair, ProxyServer::Direct()); |
| 149 EXPECT_EQ(OK, InitSession(reads, arraysize(reads), writes, arraysize(writes), | 156 EXPECT_EQ(OK, InitSession(reads, arraysize(reads), writes, arraysize(writes), |
| 150 host_port_pair)); | 157 host_port_pair)); |
| 151 | 158 |
| 152 HttpRequestInfo request; | 159 HttpRequestInfo request; |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 179 data()->CompleteRead(); | 186 data()->CompleteRead(); |
| 180 MessageLoop::current()->RunAllPending(); | 187 MessageLoop::current()->RunAllPending(); |
| 181 | 188 |
| 182 // Because we abandoned the stream, we don't expect to find a session in the | 189 // Because we abandoned the stream, we don't expect to find a session in the |
| 183 // pool anymore. | 190 // pool anymore. |
| 184 EXPECT_FALSE(http_session_->spdy_session_pool()->HasSession(pair)); | 191 EXPECT_FALSE(http_session_->spdy_session_pool()->HasSession(pair)); |
| 185 EXPECT_TRUE(data()->at_read_eof()); | 192 EXPECT_TRUE(data()->at_read_eof()); |
| 186 EXPECT_TRUE(data()->at_write_eof()); | 193 EXPECT_TRUE(data()->at_write_eof()); |
| 187 } | 194 } |
| 188 | 195 |
| 196 TEST_F(SpdyHttpStreamSpdy3Test, DelayedSendChunkedPost) { | |
| 197 // Disable merging of chunks until we have a better way to unit test POST | |
| 198 // requests with chunked uploads. | |
| 199 set_merge_chunks(false); | |
| 200 | |
| 201 const char kUploadData1[] = "12345678"; | |
| 202 const int kUploadData1Size = arraysize(kUploadData1)-1; | |
| 203 scoped_ptr<SpdyFrame> req(ConstructChunkedSpdyPost(NULL, 0)); | |
| 204 scoped_ptr<SpdyFrame> chunk1(ConstructSpdyBodyFrame(1, false)); | |
| 205 scoped_ptr<SpdyFrame> chunk2( | |
| 206 ConstructSpdyBodyFrame(1, kUploadData1, kUploadData1Size, false)); | |
| 207 scoped_ptr<SpdyFrame> chunk3(ConstructSpdyBodyFrame(1, true)); | |
| 208 MockWrite writes[] = { | |
| 209 CreateMockWrite(*req.get(), 0), | |
| 210 CreateMockWrite(*chunk1, 1), // POST upload frames | |
| 211 CreateMockWrite(*chunk2, 2), | |
| 212 CreateMockWrite(*chunk3, 3), | |
| 213 }; | |
| 214 scoped_ptr<SpdyFrame> resp(ConstructSpdyPostSynReply(NULL, 0)); | |
| 215 MockRead reads[] = { | |
| 216 CreateMockRead(*resp, 4), | |
| 217 CreateMockRead(*chunk1, 5), | |
| 218 CreateMockRead(*chunk2, 6), | |
| 219 CreateMockRead(*chunk3, 7), | |
| 220 MockRead(ASYNC, 0, 8) // EOF | |
| 221 }; | |
| 222 | |
| 223 HostPortPair host_port_pair("www.google.com", 80); | |
| 224 HostPortProxyPair pair(host_port_pair, ProxyServer::Direct()); | |
| 225 | |
| 226 scoped_ptr<DeterministicSocketData> data( | |
| 227 new DeterministicSocketData(reads, arraysize(reads), | |
| 228 writes, arraysize(writes))); | |
| 229 | |
| 230 DeterministicMockClientSocketFactory* socket_factory = | |
| 231 session_deps_.deterministic_socket_factory.get(); | |
| 232 socket_factory->AddSocketDataProvider(data.get()); | |
| 233 | |
| 234 http_session_ = SpdySessionDependencies::SpdyCreateSessionDeterministic( | |
| 235 &session_deps_); | |
| 236 session_ = http_session_->spdy_session_pool()->Get(pair, BoundNetLog()); | |
| 237 transport_params_ = new TransportSocketParams(host_port_pair, | |
| 238 MEDIUM, false, false, | |
| 239 OnHostResolutionCallback()); | |
| 240 | |
| 241 TestCompletionCallback callback; | |
| 242 scoped_ptr<ClientSocketHandle> connection(new ClientSocketHandle); | |
| 243 | |
| 244 EXPECT_EQ(ERR_IO_PENDING, | |
| 245 connection->Init(host_port_pair.ToString(), | |
| 246 transport_params_, | |
| 247 MEDIUM, | |
| 248 callback.callback(), | |
| 249 http_session_->GetTransportSocketPool( | |
| 250 HttpNetworkSession::NORMAL_SOCKET_POOL), | |
| 251 BoundNetLog())); | |
| 252 | |
| 253 callback.WaitForResult(); | |
| 254 EXPECT_EQ(OK, | |
| 255 session_->InitializeWithSocket(connection.release(), false, OK)); | |
| 256 | |
| 257 HttpRequestInfo request; | |
| 258 request.method = "POST"; | |
| 259 request.url = GURL("http://www.google.com/"); | |
| 260 request.upload_data = new UploadData(); | |
| 261 request.upload_data->set_is_chunked(true); | |
| 262 | |
| 263 BoundNetLog net_log; | |
| 264 scoped_ptr<SpdyHttpStream> http_stream( | |
| 265 new SpdyHttpStream(session_.get(), true)); | |
| 266 ASSERT_EQ(OK, | |
| 267 http_stream->InitializeStream(&request, | |
| 268 net_log, | |
| 269 CompletionCallback())); | |
| 270 | |
| 271 scoped_ptr<UploadDataStream> upload_stream( | |
| 272 new UploadDataStream(request.upload_data)); | |
| 273 ASSERT_EQ(OK, upload_stream->Init()); | |
| 274 | |
| 275 request.upload_data->AppendChunk(kUploadData, kUploadDataSize, false); | |
| 276 | |
| 277 HttpRequestHeaders headers; | |
| 278 HttpResponseInfo response; | |
| 279 // This will attempt to Write() the initial request and headers, which will | |
| 280 // complete asynchronously. | |
| 281 EXPECT_EQ(ERR_IO_PENDING, | |
| 282 http_stream->SendRequest(headers, | |
| 283 upload_stream.Pass(), | |
| 284 &response, | |
| 285 callback.callback())); | |
| 286 EXPECT_TRUE(http_session_->spdy_session_pool()->HasSession(pair)); | |
| 287 | |
| 288 // Complete the initial request write and the first chunk. | |
| 289 data->RunFor(2); | |
| 290 ASSERT_TRUE(callback.have_result()); | |
| 291 | |
| 292 // Now append the second chunk. This will enqueue another write. | |
| 293 request.upload_data->AppendChunk(kUploadData1, kUploadData1Size, false); | |
| 294 ASSERT_TRUE(callback.have_result()); | |
| 295 | |
| 296 // Now append final chunk. This will enqueue another write. | |
| 297 request.upload_data->AppendChunk(kUploadData, kUploadDataSize, true); | |
| 298 ASSERT_TRUE(callback.have_result()); | |
| 299 | |
| 300 // Finish writing all the chunks. | |
| 301 data->RunFor(2); | |
| 302 ASSERT_TRUE(callback.have_result()); | |
| 303 | |
| 304 // Read response headers. | |
| 305 data->RunFor(1); | |
| 306 int rv = callback.WaitForResult(); | |
| 307 EXPECT_GT(rv, 0); | |
| 308 EXPECT_EQ(OK, http_stream->ReadResponseHeaders(callback.callback())); | |
| 309 | |
| 310 // Read and check |chunk1| response. | |
| 311 data->RunFor(1); | |
| 312 scoped_refptr<IOBuffer> buf1(new IOBuffer(kUploadDataSize)); | |
| 313 rv = http_stream->ReadResponseBody(buf1, | |
| 314 kUploadDataSize, | |
| 315 callback.callback()); | |
| 316 ASSERT_EQ(kUploadDataSize, rv); | |
| 317 EXPECT_EQ(kUploadData, std::string(buf1->data(), kUploadDataSize)); | |
| 318 | |
| 319 // Read and check |chunk2| response. | |
| 320 data->RunFor(1); | |
| 321 scoped_refptr<IOBuffer> buf2(new IOBuffer(kUploadData1Size)); | |
| 322 rv = http_stream->ReadResponseBody(buf2, | |
| 323 kUploadData1Size, | |
| 324 callback.callback()); | |
| 325 ASSERT_EQ(kUploadData1Size, rv); | |
| 326 EXPECT_EQ(kUploadData1, std::string(buf2->data(), kUploadData1Size)); | |
| 327 | |
| 328 // Read and check |chunk3| response. | |
| 329 data->RunFor(1); | |
| 330 scoped_refptr<IOBuffer> buf3(new IOBuffer(kUploadDataSize)); | |
| 331 rv = http_stream->ReadResponseBody(buf3, | |
| 332 kUploadDataSize, | |
| 333 callback.callback()); | |
| 334 ASSERT_EQ(kUploadDataSize, rv); | |
| 335 EXPECT_EQ(kUploadData, std::string(buf3->data(), kUploadDataSize)); | |
| 336 | |
| 337 // Finish reading the |EOF|. | |
| 338 data->RunFor(1); | |
| 339 ASSERT_TRUE(response.headers.get()); | |
| 340 ASSERT_EQ(200, response.headers->response_code()); | |
| 341 EXPECT_TRUE(data->at_read_eof()); | |
| 342 EXPECT_TRUE(data->at_write_eof()); | |
| 343 } | |
| 344 | |
| 345 TEST_F(SpdyHttpStreamSpdy3Test, DelayedSendChunkedPostWithWindowUpdate) { | |
|
Ryan Hamilton
2012/07/11 17:11:19
Please add a comment here that explains we're test
ramant (doing other things)
2012/07/11 19:40:43
Done.
| |
| 346 // Disable merging of chunks until we have a better way to unit test POST | |
| 347 // requests with chunked uploads. | |
| 348 set_merge_chunks(false); | |
| 349 | |
| 350 const char kUploadData1[] = "12345678"; | |
| 351 const int kUploadData1Size = arraysize(kUploadData1)-1; | |
| 352 scoped_ptr<SpdyFrame> req(ConstructChunkedSpdyPost(NULL, 0)); | |
| 353 scoped_ptr<SpdyFrame> chunk1(ConstructSpdyBodyFrame(1, false)); | |
| 354 scoped_ptr<SpdyFrame> chunk2( | |
| 355 ConstructSpdyBodyFrame(1, kUploadData1, kUploadData1Size, false)); | |
| 356 scoped_ptr<SpdyFrame> chunk3(ConstructSpdyBodyFrame(1, true)); | |
| 357 MockWrite writes[] = { | |
| 358 CreateMockWrite(*req.get(), 0), | |
| 359 CreateMockWrite(*chunk1, 1), // POST upload frames | |
| 360 CreateMockWrite(*chunk2, 3), | |
| 361 CreateMockWrite(*chunk3, 4), | |
| 362 }; | |
| 363 scoped_ptr<SpdyFrame> resp(ConstructSpdyPostSynReply(NULL, 0)); | |
| 364 scoped_ptr<SpdyFrame> window_update( | |
| 365 ConstructSpdyWindowUpdate(1, kUploadDataSize)); | |
| 366 MockRead reads[] = { | |
| 367 CreateMockRead(*window_update, 2), | |
| 368 CreateMockRead(*resp, 5), | |
| 369 CreateMockRead(*chunk1, 6), | |
| 370 CreateMockRead(*chunk2, 7), | |
| 371 CreateMockRead(*chunk3, 8), | |
| 372 MockRead(ASYNC, 0, 9) // EOF | |
| 373 }; | |
| 374 | |
| 375 HostPortPair host_port_pair("www.google.com", 80); | |
| 376 HostPortProxyPair pair(host_port_pair, ProxyServer::Direct()); | |
| 377 | |
| 378 scoped_ptr<DeterministicSocketData> data( | |
| 379 new DeterministicSocketData(reads, arraysize(reads), | |
| 380 writes, arraysize(writes))); | |
| 381 | |
| 382 DeterministicMockClientSocketFactory* socket_factory = | |
| 383 session_deps_.deterministic_socket_factory.get(); | |
| 384 socket_factory->AddSocketDataProvider(data.get()); | |
| 385 | |
| 386 http_session_ = SpdySessionDependencies::SpdyCreateSessionDeterministic( | |
| 387 &session_deps_); | |
| 388 session_ = http_session_->spdy_session_pool()->Get(pair, BoundNetLog()); | |
| 389 transport_params_ = new TransportSocketParams(host_port_pair, | |
| 390 MEDIUM, false, false, | |
| 391 OnHostResolutionCallback()); | |
| 392 | |
| 393 TestCompletionCallback callback; | |
| 394 scoped_ptr<ClientSocketHandle> connection(new ClientSocketHandle); | |
| 395 | |
| 396 EXPECT_EQ(ERR_IO_PENDING, | |
| 397 connection->Init(host_port_pair.ToString(), | |
| 398 transport_params_, | |
| 399 MEDIUM, | |
| 400 callback.callback(), | |
| 401 http_session_->GetTransportSocketPool( | |
| 402 HttpNetworkSession::NORMAL_SOCKET_POOL), | |
| 403 BoundNetLog())); | |
| 404 | |
| 405 callback.WaitForResult(); | |
| 406 EXPECT_EQ(OK, | |
| 407 session_->InitializeWithSocket(connection.release(), false, OK)); | |
| 408 | |
| 409 HttpRequestInfo request; | |
| 410 request.method = "POST"; | |
| 411 request.url = GURL("http://www.google.com/"); | |
| 412 request.upload_data = new UploadData(); | |
| 413 request.upload_data->set_is_chunked(true); | |
| 414 | |
| 415 BoundNetLog net_log; | |
| 416 scoped_ptr<SpdyHttpStream> http_stream( | |
| 417 new SpdyHttpStream(session_.get(), true)); | |
| 418 ASSERT_EQ(OK, | |
| 419 http_stream->InitializeStream(&request, | |
| 420 net_log, | |
| 421 CompletionCallback())); | |
| 422 | |
| 423 scoped_ptr<UploadDataStream> upload_stream( | |
| 424 new UploadDataStream(request.upload_data)); | |
| 425 ASSERT_EQ(OK, upload_stream->Init()); | |
| 426 | |
| 427 request.upload_data->AppendChunk(kUploadData, kUploadDataSize, false); | |
| 428 | |
| 429 HttpRequestHeaders headers; | |
| 430 HttpResponseInfo response; | |
| 431 // This will attempt to Write() the initial request and headers, which will | |
| 432 // complete asynchronously. | |
| 433 EXPECT_EQ(ERR_IO_PENDING, | |
| 434 http_stream->SendRequest(headers, | |
| 435 upload_stream.Pass(), | |
| 436 &response, | |
| 437 callback.callback())); | |
| 438 EXPECT_TRUE(http_session_->spdy_session_pool()->HasSession(pair)); | |
| 439 | |
| 440 // Complete the initial request write, first chunk and window_update. | |
| 441 data->RunFor(2); | |
| 442 ASSERT_TRUE(callback.have_result()); | |
|
Ryan Hamilton
2012/07/11 17:11:19
I don't understand why all of these checkes for ca
ramant (doing other things)
2012/07/11 19:40:43
Done.
| |
| 443 | |
| 444 // Verify the window update. | |
| 445 ASSERT_TRUE(http_stream->stream() != NULL); | |
| 446 EXPECT_NE(static_cast<int>(kSpdyStreamInitialWindowSize), | |
| 447 http_stream->stream()->send_window_size()); | |
| 448 | |
| 449 data->RunFor(1); | |
| 450 ASSERT_TRUE(callback.have_result()); | |
| 451 | |
| 452 // Verify the window update. | |
| 453 ASSERT_TRUE(http_stream->stream() != NULL); | |
| 454 EXPECT_EQ(static_cast<int>(kSpdyStreamInitialWindowSize), | |
| 455 http_stream->stream()->send_window_size()); | |
| 456 | |
| 457 // Now append the second chunk. This will enqueue another write. | |
| 458 request.upload_data->AppendChunk(kUploadData1, kUploadData1Size, false); | |
| 459 ASSERT_TRUE(callback.have_result()); | |
| 460 | |
| 461 // Now append final chunk. This will enqueue another write. | |
| 462 request.upload_data->AppendChunk(kUploadData, kUploadDataSize, true); | |
| 463 ASSERT_TRUE(callback.have_result()); | |
| 464 | |
| 465 // Finish writing all the chunks. | |
| 466 data->RunFor(2); | |
| 467 ASSERT_TRUE(callback.have_result()); | |
| 468 | |
| 469 // Read response headers. | |
| 470 data->RunFor(1); | |
| 471 int rv = callback.WaitForResult(); | |
| 472 EXPECT_GT(rv, 0); | |
| 473 EXPECT_EQ(OK, http_stream->ReadResponseHeaders(callback.callback())); | |
| 474 | |
| 475 // Read and check |chunk1| response. | |
| 476 data->RunFor(1); | |
| 477 scoped_refptr<IOBuffer> buf1(new IOBuffer(kUploadDataSize)); | |
| 478 rv = http_stream->ReadResponseBody(buf1, | |
| 479 kUploadDataSize, | |
| 480 callback.callback()); | |
| 481 ASSERT_EQ(kUploadDataSize, rv); | |
| 482 EXPECT_EQ(kUploadData, std::string(buf1->data(), kUploadDataSize)); | |
| 483 | |
| 484 // Read and check |chunk2| response. | |
| 485 data->RunFor(1); | |
| 486 scoped_refptr<IOBuffer> buf2(new IOBuffer(kUploadData1Size)); | |
| 487 rv = http_stream->ReadResponseBody(buf2, | |
| 488 kUploadData1Size, | |
| 489 callback.callback()); | |
| 490 ASSERT_EQ(kUploadData1Size, rv); | |
| 491 EXPECT_EQ(kUploadData1, std::string(buf2->data(), kUploadData1Size)); | |
| 492 | |
| 493 // Read and check |chunk3| response. | |
| 494 data->RunFor(1); | |
| 495 scoped_refptr<IOBuffer> buf3(new IOBuffer(kUploadDataSize)); | |
| 496 rv = http_stream->ReadResponseBody(buf3, | |
| 497 kUploadDataSize, | |
| 498 callback.callback()); | |
| 499 ASSERT_EQ(kUploadDataSize, rv); | |
| 500 EXPECT_EQ(kUploadData, std::string(buf3->data(), kUploadDataSize)); | |
| 501 | |
| 502 // Finish reading the |EOF|. | |
| 503 data->RunFor(1); | |
| 504 ASSERT_TRUE(response.headers.get()); | |
| 505 ASSERT_EQ(200, response.headers->response_code()); | |
| 506 EXPECT_TRUE(data->at_read_eof()); | |
| 507 EXPECT_TRUE(data->at_write_eof()); | |
| 508 } | |
| 509 | |
| 189 // Test case for bug: http://code.google.com/p/chromium/issues/detail?id=50058 | 510 // Test case for bug: http://code.google.com/p/chromium/issues/detail?id=50058 |
| 190 TEST_F(SpdyHttpStreamSpdy3Test, SpdyURLTest) { | 511 TEST_F(SpdyHttpStreamSpdy3Test, SpdyURLTest) { |
| 191 const char * const full_url = "http://www.google.com/foo?query=what#anchor"; | 512 const char * const full_url = "http://www.google.com/foo?query=what#anchor"; |
| 192 const char * const base_url = "http://www.google.com/foo?query=what"; | 513 const char * const base_url = "http://www.google.com/foo?query=what"; |
| 193 scoped_ptr<SpdyFrame> req(ConstructSpdyGet(base_url, false, 1, LOWEST)); | 514 scoped_ptr<SpdyFrame> req(ConstructSpdyGet(base_url, false, 1, LOWEST)); |
| 194 MockWrite writes[] = { | 515 MockWrite writes[] = { |
| 195 CreateMockWrite(*req.get(), 1), | 516 CreateMockWrite(*req.get(), 1), |
| 196 }; | 517 }; |
| 197 scoped_ptr<SpdyFrame> resp(ConstructSpdyGetSynReply(NULL, 0, 1)); | 518 scoped_ptr<SpdyFrame> resp(ConstructSpdyGetSynReply(NULL, 0, 1)); |
| 198 MockRead reads[] = { | 519 MockRead reads[] = { |
| (...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 527 | 848 |
| 528 sequenced_worker_pool->Shutdown(); | 849 sequenced_worker_pool->Shutdown(); |
| 529 } | 850 } |
| 530 | 851 |
| 531 #endif // !defined(USE_OPENSSL) | 852 #endif // !defined(USE_OPENSSL) |
| 532 | 853 |
| 533 // TODO(willchan): Write a longer test for SpdyStream that exercises all | 854 // TODO(willchan): Write a longer test for SpdyStream that exercises all |
| 534 // methods. | 855 // methods. |
| 535 | 856 |
| 536 } // namespace net | 857 } // namespace net |
| OLD | NEW |