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 set_merge_chunks(false); |
| 130 | 135 |
| 131 scoped_ptr<SpdyFrame> req(ConstructChunkedSpdyPost(NULL, 0)); | 136 scoped_ptr<SpdyFrame> req(ConstructChunkedSpdyPost(NULL, 0)); |
| 132 scoped_ptr<SpdyFrame> chunk1(ConstructSpdyBodyFrame(1, false)); | 137 scoped_ptr<SpdyFrame> chunk1(ConstructSpdyBodyFrame(1, false)); |
| 133 scoped_ptr<SpdyFrame> chunk2(ConstructSpdyBodyFrame(1, true)); | 138 scoped_ptr<SpdyFrame> chunk2(ConstructSpdyBodyFrame(1, true)); |
| 134 MockWrite writes[] = { | 139 MockWrite writes[] = { |
| 135 CreateMockWrite(*req.get(), 1), | 140 CreateMockWrite(*req.get(), 0), |
| 136 CreateMockWrite(*chunk1, 2), // POST upload frames | 141 CreateMockWrite(*chunk1, 1), // POST upload frames |
| 137 CreateMockWrite(*chunk2, 3), | 142 CreateMockWrite(*chunk2, 2), |
| 138 }; | 143 }; |
| 139 scoped_ptr<SpdyFrame> resp(ConstructSpdyPostSynReply(NULL, 0)); | 144 scoped_ptr<SpdyFrame> resp(ConstructSpdyPostSynReply(NULL, 0)); |
| 140 MockRead reads[] = { | 145 MockRead reads[] = { |
| 141 CreateMockRead(*resp, 4), | 146 CreateMockRead(*resp, 3), |
| 142 CreateMockRead(*chunk1, 5), | 147 CreateMockRead(*chunk1, 4), |
| 143 CreateMockRead(*chunk2, 5), | 148 CreateMockRead(*chunk2, 5), |
| 144 MockRead(SYNCHRONOUS, 0, 6) // EOF | 149 MockRead(SYNCHRONOUS, 0, 6) // EOF |
| 145 }; | 150 }; |
| 146 | 151 |
| 147 HostPortPair host_port_pair("www.google.com", 80); | 152 HostPortPair host_port_pair("www.google.com", 80); |
| 148 HostPortProxyPair pair(host_port_pair, ProxyServer::Direct()); | 153 HostPortProxyPair pair(host_port_pair, ProxyServer::Direct()); |
| 149 EXPECT_EQ(OK, InitSession(reads, arraysize(reads), writes, arraysize(writes), | 154 EXPECT_EQ(OK, InitSession(reads, arraysize(reads), writes, arraysize(writes), |
| 150 host_port_pair)); | 155 host_port_pair)); |
| 151 | 156 |
| 152 HttpRequestInfo request; | 157 HttpRequestInfo request; |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 179 data()->CompleteRead(); | 184 data()->CompleteRead(); |
| 180 MessageLoop::current()->RunAllPending(); | 185 MessageLoop::current()->RunAllPending(); |
| 181 | 186 |
| 182 // Because we abandoned the stream, we don't expect to find a session in the | 187 // Because we abandoned the stream, we don't expect to find a session in the |
| 183 // pool anymore. | 188 // pool anymore. |
| 184 EXPECT_FALSE(http_session_->spdy_session_pool()->HasSession(pair)); | 189 EXPECT_FALSE(http_session_->spdy_session_pool()->HasSession(pair)); |
| 185 EXPECT_TRUE(data()->at_read_eof()); | 190 EXPECT_TRUE(data()->at_read_eof()); |
| 186 EXPECT_TRUE(data()->at_write_eof()); | 191 EXPECT_TRUE(data()->at_write_eof()); |
| 187 } | 192 } |
| 188 | 193 |
| 194 // Test to ensure the SpdyStream state machine does not get confused when | |
| 195 // sending a request with a chunked body, where chunks become available | |
| 196 // asynchronously, over a socket where writes may also complete asynchronously. | |
| 197 TEST_F(SpdyHttpStreamSpdy3Test, DelayedSendChunkedPost) { | |
|
Ryan Hamilton
2012/07/11 21:08:21
same comments as in _spdy2
ramant (doing other things)
2012/07/11 22:02:21
Done.
| |
| 198 set_merge_chunks(false); | |
| 199 | |
| 200 const char kUploadData1[] = "12345678"; | |
| 201 const int kUploadData1Size = arraysize(kUploadData1)-1; | |
| 202 scoped_ptr<SpdyFrame> req(ConstructChunkedSpdyPost(NULL, 0)); | |
| 203 scoped_ptr<SpdyFrame> chunk1(ConstructSpdyBodyFrame(1, false)); | |
| 204 scoped_ptr<SpdyFrame> chunk2( | |
| 205 ConstructSpdyBodyFrame(1, kUploadData1, kUploadData1Size, false)); | |
| 206 scoped_ptr<SpdyFrame> chunk3(ConstructSpdyBodyFrame(1, true)); | |
| 207 MockWrite writes[] = { | |
| 208 CreateMockWrite(*req.get(), 0), | |
| 209 CreateMockWrite(*chunk1, 1), // POST upload frames | |
| 210 CreateMockWrite(*chunk2, 2), | |
| 211 CreateMockWrite(*chunk3, 3), | |
| 212 }; | |
| 213 scoped_ptr<SpdyFrame> resp(ConstructSpdyPostSynReply(NULL, 0)); | |
| 214 MockRead reads[] = { | |
| 215 CreateMockRead(*resp, 4), | |
| 216 CreateMockRead(*chunk1, 5), | |
| 217 CreateMockRead(*chunk2, 6), | |
| 218 CreateMockRead(*chunk3, 7), | |
| 219 MockRead(ASYNC, 0, 8) // EOF | |
| 220 }; | |
| 221 | |
| 222 HostPortPair host_port_pair("www.google.com", 80); | |
| 223 HostPortProxyPair pair(host_port_pair, ProxyServer::Direct()); | |
| 224 | |
| 225 scoped_ptr<DeterministicSocketData> data( | |
| 226 new DeterministicSocketData(reads, arraysize(reads), | |
| 227 writes, arraysize(writes))); | |
| 228 | |
| 229 DeterministicMockClientSocketFactory* socket_factory = | |
| 230 session_deps_.deterministic_socket_factory.get(); | |
| 231 socket_factory->AddSocketDataProvider(data.get()); | |
| 232 | |
| 233 http_session_ = SpdySessionDependencies::SpdyCreateSessionDeterministic( | |
| 234 &session_deps_); | |
| 235 session_ = http_session_->spdy_session_pool()->Get(pair, BoundNetLog()); | |
| 236 transport_params_ = new TransportSocketParams(host_port_pair, | |
| 237 MEDIUM, false, false, | |
| 238 OnHostResolutionCallback()); | |
| 239 | |
| 240 TestCompletionCallback callback; | |
| 241 scoped_ptr<ClientSocketHandle> connection(new ClientSocketHandle); | |
| 242 | |
| 243 EXPECT_EQ(ERR_IO_PENDING, | |
| 244 connection->Init(host_port_pair.ToString(), | |
| 245 transport_params_, | |
| 246 MEDIUM, | |
| 247 callback.callback(), | |
| 248 http_session_->GetTransportSocketPool( | |
| 249 HttpNetworkSession::NORMAL_SOCKET_POOL), | |
| 250 BoundNetLog())); | |
| 251 | |
| 252 callback.WaitForResult(); | |
| 253 EXPECT_EQ(OK, | |
| 254 session_->InitializeWithSocket(connection.release(), false, OK)); | |
| 255 | |
| 256 HttpRequestInfo request; | |
| 257 request.method = "POST"; | |
| 258 request.url = GURL("http://www.google.com/"); | |
| 259 request.upload_data = new UploadData(); | |
| 260 request.upload_data->set_is_chunked(true); | |
| 261 | |
| 262 BoundNetLog net_log; | |
| 263 scoped_ptr<SpdyHttpStream> http_stream( | |
| 264 new SpdyHttpStream(session_.get(), true)); | |
| 265 ASSERT_EQ(OK, | |
| 266 http_stream->InitializeStream(&request, | |
| 267 net_log, | |
| 268 CompletionCallback())); | |
| 269 | |
| 270 scoped_ptr<UploadDataStream> upload_stream( | |
| 271 new UploadDataStream(request.upload_data)); | |
| 272 ASSERT_EQ(OK, upload_stream->Init()); | |
| 273 | |
| 274 request.upload_data->AppendChunk(kUploadData, kUploadDataSize, false); | |
| 275 | |
| 276 HttpRequestHeaders headers; | |
| 277 HttpResponseInfo response; | |
| 278 // This will attempt to Write() the initial request and headers, which will | |
| 279 // complete asynchronously. | |
| 280 EXPECT_EQ(ERR_IO_PENDING, | |
| 281 http_stream->SendRequest(headers, | |
| 282 upload_stream.Pass(), | |
| 283 &response, | |
| 284 callback.callback())); | |
| 285 EXPECT_TRUE(http_session_->spdy_session_pool()->HasSession(pair)); | |
| 286 | |
| 287 // Complete the initial request write and the first chunk. | |
| 288 data->RunFor(2); | |
| 289 ASSERT_TRUE(callback.have_result()); | |
| 290 EXPECT_GT(callback.WaitForResult(), 0); | |
| 291 | |
| 292 // Now append the second chunk. This will enqueue another write. | |
| 293 request.upload_data->AppendChunk(kUploadData1, kUploadData1Size, false); | |
| 294 | |
| 295 // Now append final chunk. This will enqueue another write. | |
| 296 request.upload_data->AppendChunk(kUploadData, kUploadDataSize, true); | |
| 297 | |
| 298 // Finish writing all the chunks. | |
| 299 data->RunFor(2); | |
| 300 | |
| 301 // Read response headers. | |
| 302 data->RunFor(1); | |
| 303 ASSERT_EQ(OK, http_stream->ReadResponseHeaders(callback.callback())); | |
| 304 | |
| 305 // Read and check |chunk1| response. | |
| 306 data->RunFor(1); | |
| 307 scoped_refptr<IOBuffer> buf1(new IOBuffer(kUploadDataSize)); | |
| 308 int rv = http_stream->ReadResponseBody(buf1, | |
| 309 kUploadDataSize, | |
| 310 callback.callback()); | |
| 311 ASSERT_EQ(kUploadDataSize, rv); | |
| 312 EXPECT_EQ(kUploadData, std::string(buf1->data(), kUploadDataSize)); | |
| 313 | |
| 314 // Read and check |chunk2| response. | |
| 315 data->RunFor(1); | |
| 316 scoped_refptr<IOBuffer> buf2(new IOBuffer(kUploadData1Size)); | |
| 317 rv = http_stream->ReadResponseBody(buf2, | |
| 318 kUploadData1Size, | |
| 319 callback.callback()); | |
| 320 ASSERT_EQ(kUploadData1Size, rv); | |
| 321 EXPECT_EQ(kUploadData1, std::string(buf2->data(), kUploadData1Size)); | |
| 322 | |
| 323 // Read and check |chunk3| response. | |
| 324 data->RunFor(1); | |
| 325 scoped_refptr<IOBuffer> buf3(new IOBuffer(kUploadDataSize)); | |
| 326 rv = http_stream->ReadResponseBody(buf3, | |
| 327 kUploadDataSize, | |
| 328 callback.callback()); | |
| 329 ASSERT_EQ(kUploadDataSize, rv); | |
| 330 EXPECT_EQ(kUploadData, std::string(buf3->data(), kUploadDataSize)); | |
| 331 | |
| 332 // Finish reading the |EOF|. | |
| 333 data->RunFor(1); | |
| 334 ASSERT_TRUE(response.headers.get()); | |
| 335 ASSERT_EQ(200, response.headers->response_code()); | |
| 336 EXPECT_TRUE(data->at_read_eof()); | |
| 337 EXPECT_TRUE(data->at_write_eof()); | |
| 338 } | |
| 339 | |
| 340 // Test the receipt of a WINDOW_UPDATE frame while waiting for a chunk to be | |
| 341 // made available is handled correctly. | |
| 342 TEST_F(SpdyHttpStreamSpdy3Test, DelayedSendChunkedPostWithWindowUpdate) { | |
| 343 set_merge_chunks(false); | |
| 344 | |
| 345 const char kUploadData1[] = "12345678"; | |
| 346 const int kUploadData1Size = arraysize(kUploadData1)-1; | |
| 347 scoped_ptr<SpdyFrame> req(ConstructChunkedSpdyPost(NULL, 0)); | |
| 348 scoped_ptr<SpdyFrame> chunk1(ConstructSpdyBodyFrame(1, false)); | |
| 349 scoped_ptr<SpdyFrame> chunk2( | |
| 350 ConstructSpdyBodyFrame(1, kUploadData1, kUploadData1Size, false)); | |
| 351 scoped_ptr<SpdyFrame> chunk3(ConstructSpdyBodyFrame(1, true)); | |
| 352 MockWrite writes[] = { | |
| 353 CreateMockWrite(*req.get(), 0), | |
| 354 CreateMockWrite(*chunk1, 1), // POST upload frames | |
| 355 CreateMockWrite(*chunk2, 3), | |
| 356 CreateMockWrite(*chunk3, 4), | |
| 357 }; | |
| 358 scoped_ptr<SpdyFrame> resp(ConstructSpdyPostSynReply(NULL, 0)); | |
| 359 scoped_ptr<SpdyFrame> window_update( | |
| 360 ConstructSpdyWindowUpdate(1, kUploadDataSize)); | |
| 361 MockRead reads[] = { | |
| 362 CreateMockRead(*window_update, 2), | |
| 363 CreateMockRead(*resp, 5), | |
| 364 CreateMockRead(*chunk1, 6), | |
| 365 CreateMockRead(*chunk2, 7), | |
| 366 CreateMockRead(*chunk3, 8), | |
| 367 MockRead(ASYNC, 0, 9) // EOF | |
| 368 }; | |
| 369 | |
| 370 HostPortPair host_port_pair("www.google.com", 80); | |
| 371 HostPortProxyPair pair(host_port_pair, ProxyServer::Direct()); | |
| 372 | |
| 373 scoped_ptr<DeterministicSocketData> data( | |
| 374 new DeterministicSocketData(reads, arraysize(reads), | |
| 375 writes, arraysize(writes))); | |
| 376 | |
| 377 DeterministicMockClientSocketFactory* socket_factory = | |
| 378 session_deps_.deterministic_socket_factory.get(); | |
| 379 socket_factory->AddSocketDataProvider(data.get()); | |
| 380 | |
| 381 http_session_ = SpdySessionDependencies::SpdyCreateSessionDeterministic( | |
| 382 &session_deps_); | |
| 383 session_ = http_session_->spdy_session_pool()->Get(pair, BoundNetLog()); | |
| 384 transport_params_ = new TransportSocketParams(host_port_pair, | |
| 385 MEDIUM, false, false, | |
| 386 OnHostResolutionCallback()); | |
| 387 | |
| 388 TestCompletionCallback callback; | |
| 389 scoped_ptr<ClientSocketHandle> connection(new ClientSocketHandle); | |
| 390 | |
| 391 EXPECT_EQ(ERR_IO_PENDING, | |
| 392 connection->Init(host_port_pair.ToString(), | |
| 393 transport_params_, | |
| 394 MEDIUM, | |
| 395 callback.callback(), | |
| 396 http_session_->GetTransportSocketPool( | |
| 397 HttpNetworkSession::NORMAL_SOCKET_POOL), | |
| 398 BoundNetLog())); | |
| 399 | |
| 400 callback.WaitForResult(); | |
| 401 EXPECT_EQ(OK, | |
| 402 session_->InitializeWithSocket(connection.release(), false, OK)); | |
| 403 | |
| 404 HttpRequestInfo request; | |
| 405 request.method = "POST"; | |
| 406 request.url = GURL("http://www.google.com/"); | |
| 407 request.upload_data = new UploadData(); | |
| 408 request.upload_data->set_is_chunked(true); | |
| 409 | |
| 410 BoundNetLog net_log; | |
| 411 scoped_ptr<SpdyHttpStream> http_stream( | |
| 412 new SpdyHttpStream(session_.get(), true)); | |
| 413 ASSERT_EQ(OK, | |
| 414 http_stream->InitializeStream(&request, | |
| 415 net_log, | |
| 416 CompletionCallback())); | |
| 417 | |
| 418 scoped_ptr<UploadDataStream> upload_stream( | |
| 419 new UploadDataStream(request.upload_data)); | |
| 420 ASSERT_EQ(OK, upload_stream->Init()); | |
| 421 | |
| 422 request.upload_data->AppendChunk(kUploadData, kUploadDataSize, false); | |
| 423 | |
| 424 HttpRequestHeaders headers; | |
| 425 HttpResponseInfo response; | |
| 426 // This will attempt to Write() the initial request and headers, which will | |
| 427 // complete asynchronously. | |
| 428 EXPECT_EQ(ERR_IO_PENDING, | |
| 429 http_stream->SendRequest(headers, | |
| 430 upload_stream.Pass(), | |
| 431 &response, | |
| 432 callback.callback())); | |
| 433 EXPECT_TRUE(http_session_->spdy_session_pool()->HasSession(pair)); | |
| 434 | |
| 435 // Complete the initial request write, first chunk and window_update. | |
| 436 data->RunFor(2); | |
| 437 ASSERT_TRUE(callback.have_result()); | |
| 438 EXPECT_GT(callback.WaitForResult(), 0); | |
| 439 | |
| 440 // Verify that the window size has decreased. | |
| 441 ASSERT_TRUE(http_stream->stream() != NULL); | |
| 442 EXPECT_NE(static_cast<int>(kSpdyStreamInitialWindowSize), | |
| 443 http_stream->stream()->send_window_size()); | |
| 444 | |
| 445 // Read window update. | |
| 446 data->RunFor(1); | |
| 447 | |
| 448 // Verify the window update. | |
| 449 ASSERT_TRUE(http_stream->stream() != NULL); | |
| 450 EXPECT_EQ(static_cast<int>(kSpdyStreamInitialWindowSize), | |
| 451 http_stream->stream()->send_window_size()); | |
| 452 | |
| 453 // Now append the second chunk. This will enqueue another write. | |
|
Ryan Hamilton
2012/07/11 21:08:21
nit: it looks like we don't need the 2nd or third
ramant (doing other things)
2012/07/11 22:02:21
Done.
ramant (doing other things)
2012/07/11 22:02:21
Deleted the third chunk. We need the 2nd chunk to
Ryan Hamilton
2012/07/11 22:51:14
Why is the 2nd chunk required? We don't AppendChu
| |
| 454 request.upload_data->AppendChunk(kUploadData1, kUploadData1Size, false); | |
| 455 | |
| 456 // Now append final chunk. This will enqueue another write. | |
| 457 request.upload_data->AppendChunk(kUploadData, kUploadDataSize, true); | |
| 458 | |
| 459 // Finish writing all the chunks. | |
| 460 data->RunFor(2); | |
| 461 | |
| 462 // Read response headers. | |
| 463 data->RunFor(1); | |
| 464 ASSERT_EQ(OK, http_stream->ReadResponseHeaders(callback.callback())); | |
| 465 | |
| 466 // Read and check |chunk1| response. | |
| 467 data->RunFor(1); | |
| 468 scoped_refptr<IOBuffer> buf1(new IOBuffer(kUploadDataSize)); | |
| 469 int rv = http_stream->ReadResponseBody(buf1, | |
| 470 kUploadDataSize, | |
| 471 callback.callback()); | |
| 472 ASSERT_EQ(kUploadDataSize, rv); | |
| 473 EXPECT_EQ(kUploadData, std::string(buf1->data(), kUploadDataSize)); | |
| 474 | |
| 475 // Read and check |chunk2| response. | |
| 476 data->RunFor(1); | |
| 477 scoped_refptr<IOBuffer> buf2(new IOBuffer(kUploadData1Size)); | |
| 478 rv = http_stream->ReadResponseBody(buf2, | |
| 479 kUploadData1Size, | |
| 480 callback.callback()); | |
| 481 ASSERT_EQ(kUploadData1Size, rv); | |
| 482 EXPECT_EQ(kUploadData1, std::string(buf2->data(), kUploadData1Size)); | |
| 483 | |
| 484 // Read and check |chunk3| response. | |
| 485 data->RunFor(1); | |
| 486 scoped_refptr<IOBuffer> buf3(new IOBuffer(kUploadDataSize)); | |
| 487 rv = http_stream->ReadResponseBody(buf3, | |
| 488 kUploadDataSize, | |
| 489 callback.callback()); | |
| 490 ASSERT_EQ(kUploadDataSize, rv); | |
| 491 EXPECT_EQ(kUploadData, std::string(buf3->data(), kUploadDataSize)); | |
| 492 | |
| 493 // Finish reading the |EOF|. | |
| 494 data->RunFor(1); | |
| 495 ASSERT_TRUE(response.headers.get()); | |
| 496 ASSERT_EQ(200, response.headers->response_code()); | |
| 497 EXPECT_TRUE(data->at_read_eof()); | |
| 498 EXPECT_TRUE(data->at_write_eof()); | |
| 499 } | |
| 500 | |
| 189 // Test case for bug: http://code.google.com/p/chromium/issues/detail?id=50058 | 501 // Test case for bug: http://code.google.com/p/chromium/issues/detail?id=50058 |
| 190 TEST_F(SpdyHttpStreamSpdy3Test, SpdyURLTest) { | 502 TEST_F(SpdyHttpStreamSpdy3Test, SpdyURLTest) { |
| 191 const char * const full_url = "http://www.google.com/foo?query=what#anchor"; | 503 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"; | 504 const char * const base_url = "http://www.google.com/foo?query=what"; |
| 193 scoped_ptr<SpdyFrame> req(ConstructSpdyGet(base_url, false, 1, LOWEST)); | 505 scoped_ptr<SpdyFrame> req(ConstructSpdyGet(base_url, false, 1, LOWEST)); |
| 194 MockWrite writes[] = { | 506 MockWrite writes[] = { |
| 195 CreateMockWrite(*req.get(), 1), | 507 CreateMockWrite(*req.get(), 1), |
| 196 }; | 508 }; |
| 197 scoped_ptr<SpdyFrame> resp(ConstructSpdyGetSynReply(NULL, 0, 1)); | 509 scoped_ptr<SpdyFrame> resp(ConstructSpdyGetSynReply(NULL, 0, 1)); |
| 198 MockRead reads[] = { | 510 MockRead reads[] = { |
| (...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 527 | 839 |
| 528 sequenced_worker_pool->Shutdown(); | 840 sequenced_worker_pool->Shutdown(); |
| 529 } | 841 } |
| 530 | 842 |
| 531 #endif // !defined(USE_OPENSSL) | 843 #endif // !defined(USE_OPENSSL) |
| 532 | 844 |
| 533 // TODO(willchan): Write a longer test for SpdyStream that exercises all | 845 // TODO(willchan): Write a longer test for SpdyStream that exercises all |
| 534 // methods. | 846 // methods. |
| 535 | 847 |
| 536 } // namespace net | 848 } // namespace net |
| OLD | NEW |