| 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 <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 SpdyHttpStream stream(session_, false); | 155 SpdyHttpStream stream(session_, false); |
| 156 UploadProgress progress = stream.GetUploadProgress(); | 156 UploadProgress progress = stream.GetUploadProgress(); |
| 157 EXPECT_EQ(0u, progress.size()); | 157 EXPECT_EQ(0u, progress.size()); |
| 158 EXPECT_EQ(0u, progress.position()); | 158 EXPECT_EQ(0u, progress.position()); |
| 159 | 159 |
| 160 // Pump the event loop so |reads| is consumed before the function returns. | 160 // Pump the event loop so |reads| is consumed before the function returns. |
| 161 base::RunLoop().RunUntilIdle(); | 161 base::RunLoop().RunUntilIdle(); |
| 162 } | 162 } |
| 163 | 163 |
| 164 TEST_P(SpdyHttpStreamTest, SendRequest) { | 164 TEST_P(SpdyHttpStreamTest, SendRequest) { |
| 165 scoped_ptr<SpdyFrame> req( | 165 scoped_ptr<SpdySerializedFrame> req( |
| 166 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, true)); | 166 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, true)); |
| 167 MockWrite writes[] = { | 167 MockWrite writes[] = { |
| 168 CreateMockWrite(*req.get(), 0), | 168 CreateMockWrite(*req.get(), 0), |
| 169 }; | 169 }; |
| 170 scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); | 170 scoped_ptr<SpdySerializedFrame> resp( |
| 171 spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); |
| 171 MockRead reads[] = { | 172 MockRead reads[] = { |
| 172 CreateMockRead(*resp, 1), MockRead(SYNCHRONOUS, 0, 2) // EOF | 173 CreateMockRead(*resp, 1), MockRead(SYNCHRONOUS, 0, 2) // EOF |
| 173 }; | 174 }; |
| 174 | 175 |
| 175 HostPortPair host_port_pair("www.example.org", 80); | 176 HostPortPair host_port_pair("www.example.org", 80); |
| 176 SpdySessionKey key(host_port_pair, ProxyServer::Direct(), | 177 SpdySessionKey key(host_port_pair, ProxyServer::Direct(), |
| 177 PRIVACY_MODE_DISABLED); | 178 PRIVACY_MODE_DISABLED); |
| 178 InitSession(reads, arraysize(reads), writes, arraysize(writes), key); | 179 InitSession(reads, arraysize(reads), writes, arraysize(writes), key); |
| 179 | 180 |
| 180 HttpRequestInfo request; | 181 HttpRequestInfo request; |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 // stream has been closed. | 216 // stream has been closed. |
| 216 TestLoadTimingNotReused(*http_stream); | 217 TestLoadTimingNotReused(*http_stream); |
| 217 | 218 |
| 218 EXPECT_EQ(static_cast<int64_t>(req->size()), | 219 EXPECT_EQ(static_cast<int64_t>(req->size()), |
| 219 http_stream->GetTotalSentBytes()); | 220 http_stream->GetTotalSentBytes()); |
| 220 EXPECT_EQ(static_cast<int64_t>(resp->size()), | 221 EXPECT_EQ(static_cast<int64_t>(resp->size()), |
| 221 http_stream->GetTotalReceivedBytes()); | 222 http_stream->GetTotalReceivedBytes()); |
| 222 } | 223 } |
| 223 | 224 |
| 224 TEST_P(SpdyHttpStreamTest, LoadTimingTwoRequests) { | 225 TEST_P(SpdyHttpStreamTest, LoadTimingTwoRequests) { |
| 225 scoped_ptr<SpdyFrame> req1( | 226 scoped_ptr<SpdySerializedFrame> req1( |
| 226 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, true)); | 227 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, true)); |
| 227 scoped_ptr<SpdyFrame> req2( | 228 scoped_ptr<SpdySerializedFrame> req2( |
| 228 spdy_util_.ConstructSpdyGet(nullptr, 0, 3, LOWEST, true)); | 229 spdy_util_.ConstructSpdyGet(nullptr, 0, 3, LOWEST, true)); |
| 229 MockWrite writes[] = { | 230 MockWrite writes[] = { |
| 230 CreateMockWrite(*req1, 0), | 231 CreateMockWrite(*req1, 0), |
| 231 CreateMockWrite(*req2, 1), | 232 CreateMockWrite(*req2, 1), |
| 232 }; | 233 }; |
| 233 scoped_ptr<SpdyFrame> resp1( | 234 scoped_ptr<SpdySerializedFrame> resp1( |
| 234 spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); | 235 spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); |
| 235 scoped_ptr<SpdyFrame> body1( | 236 scoped_ptr<SpdySerializedFrame> body1( |
| 236 spdy_util_.ConstructSpdyBodyFrame(1, "", 0, true)); | 237 spdy_util_.ConstructSpdyBodyFrame(1, "", 0, true)); |
| 237 scoped_ptr<SpdyFrame> resp2( | 238 scoped_ptr<SpdySerializedFrame> resp2( |
| 238 spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 3)); | 239 spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 3)); |
| 239 scoped_ptr<SpdyFrame> body2( | 240 scoped_ptr<SpdySerializedFrame> body2( |
| 240 spdy_util_.ConstructSpdyBodyFrame(3, "", 0, true)); | 241 spdy_util_.ConstructSpdyBodyFrame(3, "", 0, true)); |
| 241 MockRead reads[] = { | 242 MockRead reads[] = { |
| 242 CreateMockRead(*resp1, 2), | 243 CreateMockRead(*resp1, 2), |
| 243 CreateMockRead(*body1, 3), | 244 CreateMockRead(*body1, 3), |
| 244 CreateMockRead(*resp2, 4), | 245 CreateMockRead(*resp2, 4), |
| 245 CreateMockRead(*body2, 5), | 246 CreateMockRead(*body2, 5), |
| 246 MockRead(ASYNC, 0, 6) // EOF | 247 MockRead(ASYNC, 0, 6) // EOF |
| 247 }; | 248 }; |
| 248 | 249 |
| 249 HostPortPair host_port_pair("www.example.org", 80); | 250 HostPortPair host_port_pair("www.example.org", 80); |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 317 | 318 |
| 318 EXPECT_EQ(static_cast<int64_t>(req2->size()), | 319 EXPECT_EQ(static_cast<int64_t>(req2->size()), |
| 319 http_stream2->GetTotalSentBytes()); | 320 http_stream2->GetTotalSentBytes()); |
| 320 EXPECT_EQ(static_cast<int64_t>(resp2->size() + body2->size()), | 321 EXPECT_EQ(static_cast<int64_t>(resp2->size() + body2->size()), |
| 321 http_stream2->GetTotalReceivedBytes()); | 322 http_stream2->GetTotalReceivedBytes()); |
| 322 } | 323 } |
| 323 | 324 |
| 324 TEST_P(SpdyHttpStreamTest, SendChunkedPost) { | 325 TEST_P(SpdyHttpStreamTest, SendChunkedPost) { |
| 325 BufferedSpdyFramer framer(spdy_util_.spdy_version()); | 326 BufferedSpdyFramer framer(spdy_util_.spdy_version()); |
| 326 | 327 |
| 327 scoped_ptr<SpdyFrame> req( | 328 scoped_ptr<SpdySerializedFrame> req( |
| 328 spdy_util_.ConstructChunkedSpdyPost(NULL, 0)); | 329 spdy_util_.ConstructChunkedSpdyPost(NULL, 0)); |
| 329 scoped_ptr<SpdyFrame> body( | 330 scoped_ptr<SpdySerializedFrame> body( |
| 330 framer.CreateDataFrame(1, kUploadData, kUploadDataSize, DATA_FLAG_FIN)); | 331 framer.CreateDataFrame(1, kUploadData, kUploadDataSize, DATA_FLAG_FIN)); |
| 331 MockWrite writes[] = { | 332 MockWrite writes[] = { |
| 332 CreateMockWrite(*req, 0), // request | 333 CreateMockWrite(*req, 0), // request |
| 333 CreateMockWrite(*body, 1) // POST upload frame | 334 CreateMockWrite(*body, 1) // POST upload frame |
| 334 }; | 335 }; |
| 335 | 336 |
| 336 scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyPostSynReply(NULL, 0)); | 337 scoped_ptr<SpdySerializedFrame> resp( |
| 338 spdy_util_.ConstructSpdyPostSynReply(NULL, 0)); |
| 337 MockRead reads[] = { | 339 MockRead reads[] = { |
| 338 CreateMockRead(*resp, 2), | 340 CreateMockRead(*resp, 2), |
| 339 CreateMockRead(*body, 3), | 341 CreateMockRead(*body, 3), |
| 340 MockRead(SYNCHRONOUS, 0, 4) // EOF | 342 MockRead(SYNCHRONOUS, 0, 4) // EOF |
| 341 }; | 343 }; |
| 342 | 344 |
| 343 HostPortPair host_port_pair("www.example.org", 80); | 345 HostPortPair host_port_pair("www.example.org", 80); |
| 344 SpdySessionKey key(host_port_pair, ProxyServer::Direct(), | 346 SpdySessionKey key(host_port_pair, ProxyServer::Direct(), |
| 345 PRIVACY_MODE_DISABLED); | 347 PRIVACY_MODE_DISABLED); |
| 346 InitSession(reads, arraysize(reads), writes, arraysize(writes), key); | 348 InitSession(reads, arraysize(reads), writes, arraysize(writes), key); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 381 http_stream.GetTotalReceivedBytes()); | 383 http_stream.GetTotalReceivedBytes()); |
| 382 | 384 |
| 383 // Because the server closed the connection, we there shouldn't be a session | 385 // Because the server closed the connection, we there shouldn't be a session |
| 384 // in the pool anymore. | 386 // in the pool anymore. |
| 385 EXPECT_FALSE(HasSpdySession(http_session_->spdy_session_pool(), key)); | 387 EXPECT_FALSE(HasSpdySession(http_session_->spdy_session_pool(), key)); |
| 386 } | 388 } |
| 387 | 389 |
| 388 TEST_P(SpdyHttpStreamTest, ConnectionClosedDuringChunkedPost) { | 390 TEST_P(SpdyHttpStreamTest, ConnectionClosedDuringChunkedPost) { |
| 389 BufferedSpdyFramer framer(spdy_util_.spdy_version()); | 391 BufferedSpdyFramer framer(spdy_util_.spdy_version()); |
| 390 | 392 |
| 391 scoped_ptr<SpdyFrame> req(spdy_util_.ConstructChunkedSpdyPost(NULL, 0)); | 393 scoped_ptr<SpdySerializedFrame> req( |
| 392 scoped_ptr<SpdyFrame> body( | 394 spdy_util_.ConstructChunkedSpdyPost(NULL, 0)); |
| 395 scoped_ptr<SpdySerializedFrame> body( |
| 393 framer.CreateDataFrame(1, kUploadData, kUploadDataSize, DATA_FLAG_NONE)); | 396 framer.CreateDataFrame(1, kUploadData, kUploadDataSize, DATA_FLAG_NONE)); |
| 394 MockWrite writes[] = { | 397 MockWrite writes[] = { |
| 395 CreateMockWrite(*req, 0), // Request | 398 CreateMockWrite(*req, 0), // Request |
| 396 CreateMockWrite(*body, 1) // First POST upload frame | 399 CreateMockWrite(*body, 1) // First POST upload frame |
| 397 }; | 400 }; |
| 398 | 401 |
| 399 scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyPostSynReply(NULL, 0)); | 402 scoped_ptr<SpdySerializedFrame> resp( |
| 403 spdy_util_.ConstructSpdyPostSynReply(NULL, 0)); |
| 400 MockRead reads[] = { | 404 MockRead reads[] = { |
| 401 MockRead(ASYNC, ERR_CONNECTION_CLOSED, 2) // Server hangs up early. | 405 MockRead(ASYNC, ERR_CONNECTION_CLOSED, 2) // Server hangs up early. |
| 402 }; | 406 }; |
| 403 | 407 |
| 404 HostPortPair host_port_pair("www.example.org", 80); | 408 HostPortPair host_port_pair("www.example.org", 80); |
| 405 SpdySessionKey key(host_port_pair, ProxyServer::Direct(), | 409 SpdySessionKey key(host_port_pair, ProxyServer::Direct(), |
| 406 PRIVACY_MODE_DISABLED); | 410 PRIVACY_MODE_DISABLED); |
| 407 InitSession(reads, arraysize(reads), writes, arraysize(writes), key); | 411 InitSession(reads, arraysize(reads), writes, arraysize(writes), key); |
| 408 EXPECT_EQ(spdy_util_.spdy_version(), session_->GetProtocolVersion()); | 412 EXPECT_EQ(spdy_util_.spdy_version(), session_->GetProtocolVersion()); |
| 409 | 413 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 450 EXPECT_EQ(static_cast<int64_t>(req->size() + body->size()), | 454 EXPECT_EQ(static_cast<int64_t>(req->size() + body->size()), |
| 451 http_stream.GetTotalSentBytes()); | 455 http_stream.GetTotalSentBytes()); |
| 452 EXPECT_EQ(0, http_stream.GetTotalReceivedBytes()); | 456 EXPECT_EQ(0, http_stream.GetTotalReceivedBytes()); |
| 453 } | 457 } |
| 454 | 458 |
| 455 // Test to ensure the SpdyStream state machine does not get confused when a | 459 // Test to ensure the SpdyStream state machine does not get confused when a |
| 456 // chunk becomes available while a write is pending. | 460 // chunk becomes available while a write is pending. |
| 457 TEST_P(SpdyHttpStreamTest, DelayedSendChunkedPost) { | 461 TEST_P(SpdyHttpStreamTest, DelayedSendChunkedPost) { |
| 458 const char kUploadData1[] = "12345678"; | 462 const char kUploadData1[] = "12345678"; |
| 459 const int kUploadData1Size = arraysize(kUploadData1)-1; | 463 const int kUploadData1Size = arraysize(kUploadData1)-1; |
| 460 scoped_ptr<SpdyFrame> req(spdy_util_.ConstructChunkedSpdyPost(NULL, 0)); | 464 scoped_ptr<SpdySerializedFrame> req( |
| 461 scoped_ptr<SpdyFrame> chunk1(spdy_util_.ConstructSpdyBodyFrame(1, false)); | 465 spdy_util_.ConstructChunkedSpdyPost(NULL, 0)); |
| 462 scoped_ptr<SpdyFrame> chunk2( | 466 scoped_ptr<SpdySerializedFrame> chunk1( |
| 463 spdy_util_.ConstructSpdyBodyFrame( | 467 spdy_util_.ConstructSpdyBodyFrame(1, false)); |
| 464 1, kUploadData1, kUploadData1Size, false)); | 468 scoped_ptr<SpdySerializedFrame> chunk2(spdy_util_.ConstructSpdyBodyFrame( |
| 465 scoped_ptr<SpdyFrame> chunk3(spdy_util_.ConstructSpdyBodyFrame(1, true)); | 469 1, kUploadData1, kUploadData1Size, false)); |
| 470 scoped_ptr<SpdySerializedFrame> chunk3( |
| 471 spdy_util_.ConstructSpdyBodyFrame(1, true)); |
| 466 MockWrite writes[] = { | 472 MockWrite writes[] = { |
| 467 CreateMockWrite(*req.get(), 0), | 473 CreateMockWrite(*req.get(), 0), |
| 468 CreateMockWrite(*chunk1, 1), // POST upload frames | 474 CreateMockWrite(*chunk1, 1), // POST upload frames |
| 469 CreateMockWrite(*chunk2, 2), | 475 CreateMockWrite(*chunk2, 2), |
| 470 CreateMockWrite(*chunk3, 3), | 476 CreateMockWrite(*chunk3, 3), |
| 471 }; | 477 }; |
| 472 scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyPostSynReply(NULL, 0)); | 478 scoped_ptr<SpdySerializedFrame> resp( |
| 479 spdy_util_.ConstructSpdyPostSynReply(NULL, 0)); |
| 473 MockRead reads[] = { | 480 MockRead reads[] = { |
| 474 CreateMockRead(*resp, 4), | 481 CreateMockRead(*resp, 4), |
| 475 CreateMockRead(*chunk1, 5), | 482 CreateMockRead(*chunk1, 5), |
| 476 CreateMockRead(*chunk2, 6), | 483 CreateMockRead(*chunk2, 6), |
| 477 CreateMockRead(*chunk3, 7), | 484 CreateMockRead(*chunk3, 7), |
| 478 MockRead(ASYNC, 0, 8) // EOF | 485 MockRead(ASYNC, 0, 8) // EOF |
| 479 }; | 486 }; |
| 480 | 487 |
| 481 HostPortPair host_port_pair("www.example.org", 80); | 488 HostPortPair host_port_pair("www.example.org", 80); |
| 482 SpdySessionKey key(host_port_pair, ProxyServer::Direct(), | 489 SpdySessionKey key(host_port_pair, ProxyServer::Direct(), |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 550 buf3.get(), kUploadDataSize, callback.callback())); | 557 buf3.get(), kUploadDataSize, callback.callback())); |
| 551 EXPECT_EQ(kUploadData, std::string(buf3->data(), kUploadDataSize)); | 558 EXPECT_EQ(kUploadData, std::string(buf3->data(), kUploadDataSize)); |
| 552 | 559 |
| 553 ASSERT_TRUE(response.headers.get()); | 560 ASSERT_TRUE(response.headers.get()); |
| 554 ASSERT_EQ(200, response.headers->response_code()); | 561 ASSERT_EQ(200, response.headers->response_code()); |
| 555 } | 562 } |
| 556 | 563 |
| 557 // Test that the SpdyStream state machine can handle sending a final empty data | 564 // Test that the SpdyStream state machine can handle sending a final empty data |
| 558 // frame when uploading a chunked data stream. | 565 // frame when uploading a chunked data stream. |
| 559 TEST_P(SpdyHttpStreamTest, DelayedSendChunkedPostWithEmptyFinalDataFrame) { | 566 TEST_P(SpdyHttpStreamTest, DelayedSendChunkedPostWithEmptyFinalDataFrame) { |
| 560 scoped_ptr<SpdyFrame> req(spdy_util_.ConstructChunkedSpdyPost(NULL, 0)); | 567 scoped_ptr<SpdySerializedFrame> req( |
| 561 scoped_ptr<SpdyFrame> chunk1(spdy_util_.ConstructSpdyBodyFrame(1, false)); | 568 spdy_util_.ConstructChunkedSpdyPost(NULL, 0)); |
| 562 scoped_ptr<SpdyFrame> chunk2( | 569 scoped_ptr<SpdySerializedFrame> chunk1( |
| 570 spdy_util_.ConstructSpdyBodyFrame(1, false)); |
| 571 scoped_ptr<SpdySerializedFrame> chunk2( |
| 563 spdy_util_.ConstructSpdyBodyFrame(1, "", 0, true)); | 572 spdy_util_.ConstructSpdyBodyFrame(1, "", 0, true)); |
| 564 MockWrite writes[] = { | 573 MockWrite writes[] = { |
| 565 CreateMockWrite(*req.get(), 0), | 574 CreateMockWrite(*req.get(), 0), |
| 566 CreateMockWrite(*chunk1, 1), // POST upload frames | 575 CreateMockWrite(*chunk1, 1), // POST upload frames |
| 567 CreateMockWrite(*chunk2, 2), | 576 CreateMockWrite(*chunk2, 2), |
| 568 }; | 577 }; |
| 569 scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyPostSynReply(NULL, 0)); | 578 scoped_ptr<SpdySerializedFrame> resp( |
| 579 spdy_util_.ConstructSpdyPostSynReply(NULL, 0)); |
| 570 MockRead reads[] = { | 580 MockRead reads[] = { |
| 571 CreateMockRead(*resp, 3), | 581 CreateMockRead(*resp, 3), |
| 572 CreateMockRead(*chunk1, 4), | 582 CreateMockRead(*chunk1, 4), |
| 573 CreateMockRead(*chunk2, 5), | 583 CreateMockRead(*chunk2, 5), |
| 574 MockRead(ASYNC, 0, 6) // EOF | 584 MockRead(ASYNC, 0, 6) // EOF |
| 575 }; | 585 }; |
| 576 | 586 |
| 577 HostPortPair host_port_pair("www.example.org", 80); | 587 HostPortPair host_port_pair("www.example.org", 80); |
| 578 SpdySessionKey key(host_port_pair, ProxyServer::Direct(), | 588 SpdySessionKey key(host_port_pair, ProxyServer::Direct(), |
| 579 PRIVACY_MODE_DISABLED); | 589 PRIVACY_MODE_DISABLED); |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 639 http_stream->ReadResponseBody( | 649 http_stream->ReadResponseBody( |
| 640 buf1.get(), kUploadDataSize, callback.callback())); | 650 buf1.get(), kUploadDataSize, callback.callback())); |
| 641 | 651 |
| 642 ASSERT_TRUE(response.headers.get()); | 652 ASSERT_TRUE(response.headers.get()); |
| 643 ASSERT_EQ(200, response.headers->response_code()); | 653 ASSERT_EQ(200, response.headers->response_code()); |
| 644 } | 654 } |
| 645 | 655 |
| 646 // Test that the SpdyStream state machine handles a chunked upload with no | 656 // Test that the SpdyStream state machine handles a chunked upload with no |
| 647 // payload. Unclear if this is a case worth supporting. | 657 // payload. Unclear if this is a case worth supporting. |
| 648 TEST_P(SpdyHttpStreamTest, ChunkedPostWithEmptyPayload) { | 658 TEST_P(SpdyHttpStreamTest, ChunkedPostWithEmptyPayload) { |
| 649 scoped_ptr<SpdyFrame> req(spdy_util_.ConstructChunkedSpdyPost(NULL, 0)); | 659 scoped_ptr<SpdySerializedFrame> req( |
| 650 scoped_ptr<SpdyFrame> chunk( | 660 spdy_util_.ConstructChunkedSpdyPost(NULL, 0)); |
| 661 scoped_ptr<SpdySerializedFrame> chunk( |
| 651 spdy_util_.ConstructSpdyBodyFrame(1, "", 0, true)); | 662 spdy_util_.ConstructSpdyBodyFrame(1, "", 0, true)); |
| 652 MockWrite writes[] = { | 663 MockWrite writes[] = { |
| 653 CreateMockWrite(*req.get(), 0), | 664 CreateMockWrite(*req.get(), 0), |
| 654 CreateMockWrite(*chunk, 1), | 665 CreateMockWrite(*chunk, 1), |
| 655 }; | 666 }; |
| 656 scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyPostSynReply(NULL, 0)); | 667 scoped_ptr<SpdySerializedFrame> resp( |
| 668 spdy_util_.ConstructSpdyPostSynReply(NULL, 0)); |
| 657 MockRead reads[] = { | 669 MockRead reads[] = { |
| 658 CreateMockRead(*resp, 2), | 670 CreateMockRead(*resp, 2), |
| 659 CreateMockRead(*chunk, 3), | 671 CreateMockRead(*chunk, 3), |
| 660 MockRead(ASYNC, 0, 4) // EOF | 672 MockRead(ASYNC, 0, 4) // EOF |
| 661 }; | 673 }; |
| 662 | 674 |
| 663 HostPortPair host_port_pair("www.example.org", 80); | 675 HostPortPair host_port_pair("www.example.org", 80); |
| 664 SpdySessionKey key(host_port_pair, ProxyServer::Direct(), | 676 SpdySessionKey key(host_port_pair, ProxyServer::Direct(), |
| 665 PRIVACY_MODE_DISABLED); | 677 PRIVACY_MODE_DISABLED); |
| 666 InitSession(reads, arraysize(reads), writes, arraysize(writes), key); | 678 InitSession(reads, arraysize(reads), writes, arraysize(writes), key); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 709 buf.get(), 1, callback.callback())); | 721 buf.get(), 1, callback.callback())); |
| 710 | 722 |
| 711 ASSERT_TRUE(response.headers.get()); | 723 ASSERT_TRUE(response.headers.get()); |
| 712 ASSERT_EQ(200, response.headers->response_code()); | 724 ASSERT_EQ(200, response.headers->response_code()); |
| 713 } | 725 } |
| 714 | 726 |
| 715 // Test case for bug: http://code.google.com/p/chromium/issues/detail?id=50058 | 727 // Test case for bug: http://code.google.com/p/chromium/issues/detail?id=50058 |
| 716 TEST_P(SpdyHttpStreamTest, SpdyURLTest) { | 728 TEST_P(SpdyHttpStreamTest, SpdyURLTest) { |
| 717 const char* const full_url = "http://www.example.org/foo?query=what#anchor"; | 729 const char* const full_url = "http://www.example.org/foo?query=what#anchor"; |
| 718 const char* const base_url = "http://www.example.org/foo?query=what"; | 730 const char* const base_url = "http://www.example.org/foo?query=what"; |
| 719 scoped_ptr<SpdyFrame> req(spdy_util_.ConstructSpdyGet(base_url, 1, LOWEST)); | 731 scoped_ptr<SpdySerializedFrame> req( |
| 732 spdy_util_.ConstructSpdyGet(base_url, 1, LOWEST)); |
| 720 MockWrite writes[] = { | 733 MockWrite writes[] = { |
| 721 CreateMockWrite(*req.get(), 0), | 734 CreateMockWrite(*req.get(), 0), |
| 722 }; | 735 }; |
| 723 scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); | 736 scoped_ptr<SpdySerializedFrame> resp( |
| 737 spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); |
| 724 MockRead reads[] = { | 738 MockRead reads[] = { |
| 725 CreateMockRead(*resp, 1), MockRead(SYNCHRONOUS, 0, 2) // EOF | 739 CreateMockRead(*resp, 1), MockRead(SYNCHRONOUS, 0, 2) // EOF |
| 726 }; | 740 }; |
| 727 | 741 |
| 728 HostPortPair host_port_pair("www.example.org", 80); | 742 HostPortPair host_port_pair("www.example.org", 80); |
| 729 SpdySessionKey key(host_port_pair, ProxyServer::Direct(), | 743 SpdySessionKey key(host_port_pair, ProxyServer::Direct(), |
| 730 PRIVACY_MODE_DISABLED); | 744 PRIVACY_MODE_DISABLED); |
| 731 InitSession(reads, arraysize(reads), writes, arraysize(writes), key); | 745 InitSession(reads, arraysize(reads), writes, arraysize(writes), key); |
| 732 | 746 |
| 733 HttpRequestInfo request; | 747 HttpRequestInfo request; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 755 http_stream->GetTotalReceivedBytes()); | 769 http_stream->GetTotalReceivedBytes()); |
| 756 | 770 |
| 757 // Because we abandoned the stream, we don't expect to find a session in the | 771 // Because we abandoned the stream, we don't expect to find a session in the |
| 758 // pool anymore. | 772 // pool anymore. |
| 759 EXPECT_FALSE(HasSpdySession(http_session_->spdy_session_pool(), key)); | 773 EXPECT_FALSE(HasSpdySession(http_session_->spdy_session_pool(), key)); |
| 760 } | 774 } |
| 761 | 775 |
| 762 // Test the receipt of a WINDOW_UPDATE frame while waiting for a chunk to be | 776 // Test the receipt of a WINDOW_UPDATE frame while waiting for a chunk to be |
| 763 // made available is handled correctly. | 777 // made available is handled correctly. |
| 764 TEST_P(SpdyHttpStreamTest, DelayedSendChunkedPostWithWindowUpdate) { | 778 TEST_P(SpdyHttpStreamTest, DelayedSendChunkedPostWithWindowUpdate) { |
| 765 scoped_ptr<SpdyFrame> req(spdy_util_.ConstructChunkedSpdyPost(NULL, 0)); | 779 scoped_ptr<SpdySerializedFrame> req( |
| 766 scoped_ptr<SpdyFrame> chunk1(spdy_util_.ConstructSpdyBodyFrame(1, true)); | 780 spdy_util_.ConstructChunkedSpdyPost(NULL, 0)); |
| 781 scoped_ptr<SpdySerializedFrame> chunk1( |
| 782 spdy_util_.ConstructSpdyBodyFrame(1, true)); |
| 767 MockWrite writes[] = { | 783 MockWrite writes[] = { |
| 768 CreateMockWrite(*req.get(), 0), | 784 CreateMockWrite(*req.get(), 0), |
| 769 CreateMockWrite(*chunk1, 1), | 785 CreateMockWrite(*chunk1, 1), |
| 770 }; | 786 }; |
| 771 scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyPostSynReply(NULL, 0)); | 787 scoped_ptr<SpdySerializedFrame> resp( |
| 772 scoped_ptr<SpdyFrame> window_update( | 788 spdy_util_.ConstructSpdyPostSynReply(NULL, 0)); |
| 789 scoped_ptr<SpdySerializedFrame> window_update( |
| 773 spdy_util_.ConstructSpdyWindowUpdate(1, kUploadDataSize)); | 790 spdy_util_.ConstructSpdyWindowUpdate(1, kUploadDataSize)); |
| 774 MockRead reads[] = { | 791 MockRead reads[] = { |
| 775 CreateMockRead(*window_update, 2), | 792 CreateMockRead(*window_update, 2), |
| 776 MockRead(ASYNC, ERR_IO_PENDING, 3), | 793 MockRead(ASYNC, ERR_IO_PENDING, 3), |
| 777 CreateMockRead(*resp, 4), | 794 CreateMockRead(*resp, 4), |
| 778 CreateMockRead(*chunk1, 5), | 795 CreateMockRead(*chunk1, 5), |
| 779 MockRead(ASYNC, 0, 6) // EOF | 796 MockRead(ASYNC, 0, 6) // EOF |
| 780 }; | 797 }; |
| 781 | 798 |
| 782 HostPortPair host_port_pair("www.example.org", 80); | 799 HostPortPair host_port_pair("www.example.org", 80); |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 859 EXPECT_EQ(kUploadData, std::string(buf1->data(), kUploadDataSize)); | 876 EXPECT_EQ(kUploadData, std::string(buf1->data(), kUploadDataSize)); |
| 860 | 877 |
| 861 ASSERT_TRUE(response.headers.get()); | 878 ASSERT_TRUE(response.headers.get()); |
| 862 ASSERT_EQ(200, response.headers->response_code()); | 879 ASSERT_EQ(200, response.headers->response_code()); |
| 863 } | 880 } |
| 864 | 881 |
| 865 // TODO(willchan): Write a longer test for SpdyStream that exercises all | 882 // TODO(willchan): Write a longer test for SpdyStream that exercises all |
| 866 // methods. | 883 // methods. |
| 867 | 884 |
| 868 } // namespace net | 885 } // namespace net |
| OLD | NEW |