| 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 <memory> | 9 #include <memory> |
| 10 | 10 |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 // Pump the event loop so |reads| is consumed before the function returns. | 185 // Pump the event loop so |reads| is consumed before the function returns. |
| 186 base::RunLoop().RunUntilIdle(); | 186 base::RunLoop().RunUntilIdle(); |
| 187 } | 187 } |
| 188 | 188 |
| 189 TEST_F(SpdyHttpStreamTest, SendRequest) { | 189 TEST_F(SpdyHttpStreamTest, SendRequest) { |
| 190 SpdySerializedFrame req( | 190 SpdySerializedFrame req( |
| 191 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, true)); | 191 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, true)); |
| 192 MockWrite writes[] = { | 192 MockWrite writes[] = { |
| 193 CreateMockWrite(req, 0), | 193 CreateMockWrite(req, 0), |
| 194 }; | 194 }; |
| 195 SpdySerializedFrame resp(spdy_util_.ConstructSpdyGetSynReply(nullptr, 0, 1)); | 195 SpdySerializedFrame resp(spdy_util_.ConstructSpdyGetReply(nullptr, 0, 1)); |
| 196 MockRead reads[] = { | 196 MockRead reads[] = { |
| 197 CreateMockRead(resp, 1), MockRead(SYNCHRONOUS, 0, 2) // EOF | 197 CreateMockRead(resp, 1), MockRead(SYNCHRONOUS, 0, 2) // EOF |
| 198 }; | 198 }; |
| 199 | 199 |
| 200 InitSession(reads, arraysize(reads), writes, arraysize(writes)); | 200 InitSession(reads, arraysize(reads), writes, arraysize(writes)); |
| 201 | 201 |
| 202 HttpRequestInfo request; | 202 HttpRequestInfo request; |
| 203 request.method = "GET"; | 203 request.method = "GET"; |
| 204 request.url = GURL("http://www.example.org/"); | 204 request.url = GURL("http://www.example.org/"); |
| 205 TestCompletionCallback callback; | 205 TestCompletionCallback callback; |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 244 } | 244 } |
| 245 | 245 |
| 246 TEST_F(SpdyHttpStreamTest, LoadTimingTwoRequests) { | 246 TEST_F(SpdyHttpStreamTest, LoadTimingTwoRequests) { |
| 247 SpdySerializedFrame req1( | 247 SpdySerializedFrame req1( |
| 248 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, true)); | 248 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST, true)); |
| 249 SpdySerializedFrame req2( | 249 SpdySerializedFrame req2( |
| 250 spdy_util_.ConstructSpdyGet(nullptr, 0, 3, LOWEST, true)); | 250 spdy_util_.ConstructSpdyGet(nullptr, 0, 3, LOWEST, true)); |
| 251 MockWrite writes[] = { | 251 MockWrite writes[] = { |
| 252 CreateMockWrite(req1, 0), CreateMockWrite(req2, 1), | 252 CreateMockWrite(req1, 0), CreateMockWrite(req2, 1), |
| 253 }; | 253 }; |
| 254 SpdySerializedFrame resp1(spdy_util_.ConstructSpdyGetSynReply(nullptr, 0, 1)); | 254 SpdySerializedFrame resp1(spdy_util_.ConstructSpdyGetReply(nullptr, 0, 1)); |
| 255 SpdySerializedFrame body1(spdy_util_.ConstructSpdyDataFrame(1, "", 0, true)); | 255 SpdySerializedFrame body1(spdy_util_.ConstructSpdyDataFrame(1, "", 0, true)); |
| 256 SpdySerializedFrame resp2(spdy_util_.ConstructSpdyGetSynReply(nullptr, 0, 3)); | 256 SpdySerializedFrame resp2(spdy_util_.ConstructSpdyGetReply(nullptr, 0, 3)); |
| 257 SpdySerializedFrame body2(spdy_util_.ConstructSpdyDataFrame(3, "", 0, true)); | 257 SpdySerializedFrame body2(spdy_util_.ConstructSpdyDataFrame(3, "", 0, true)); |
| 258 MockRead reads[] = { | 258 MockRead reads[] = { |
| 259 CreateMockRead(resp1, 2), CreateMockRead(body1, 3), | 259 CreateMockRead(resp1, 2), CreateMockRead(body1, 3), |
| 260 CreateMockRead(resp2, 4), CreateMockRead(body2, 5), | 260 CreateMockRead(resp2, 4), CreateMockRead(body2, 5), |
| 261 MockRead(ASYNC, 0, 6) // EOF | 261 MockRead(ASYNC, 0, 6) // EOF |
| 262 }; | 262 }; |
| 263 | 263 |
| 264 InitSession(reads, arraysize(reads), writes, arraysize(writes)); | 264 InitSession(reads, arraysize(reads), writes, arraysize(writes)); |
| 265 | 265 |
| 266 HttpRequestInfo request1; | 266 HttpRequestInfo request1; |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 338 TEST_F(SpdyHttpStreamTest, SendChunkedPost) { | 338 TEST_F(SpdyHttpStreamTest, SendChunkedPost) { |
| 339 SpdySerializedFrame req(spdy_util_.ConstructChunkedSpdyPost(nullptr, 0)); | 339 SpdySerializedFrame req(spdy_util_.ConstructChunkedSpdyPost(nullptr, 0)); |
| 340 SpdySerializedFrame body(spdy_util_.ConstructSpdyDataFrame(1, kUploadData, | 340 SpdySerializedFrame body(spdy_util_.ConstructSpdyDataFrame(1, kUploadData, |
| 341 kUploadDataSize, | 341 kUploadDataSize, |
| 342 /*fin=*/true)); | 342 /*fin=*/true)); |
| 343 MockWrite writes[] = { | 343 MockWrite writes[] = { |
| 344 CreateMockWrite(req, 0), // request | 344 CreateMockWrite(req, 0), // request |
| 345 CreateMockWrite(body, 1) // POST upload frame | 345 CreateMockWrite(body, 1) // POST upload frame |
| 346 }; | 346 }; |
| 347 | 347 |
| 348 SpdySerializedFrame resp(spdy_util_.ConstructSpdyPostSynReply(nullptr, 0)); | 348 SpdySerializedFrame resp(spdy_util_.ConstructSpdyPostReply(nullptr, 0)); |
| 349 MockRead reads[] = { | 349 MockRead reads[] = { |
| 350 CreateMockRead(resp, 2), CreateMockRead(body, 3), | 350 CreateMockRead(resp, 2), CreateMockRead(body, 3), |
| 351 MockRead(SYNCHRONOUS, 0, 4) // EOF | 351 MockRead(SYNCHRONOUS, 0, 4) // EOF |
| 352 }; | 352 }; |
| 353 | 353 |
| 354 InitSession(reads, arraysize(reads), writes, arraysize(writes)); | 354 InitSession(reads, arraysize(reads), writes, arraysize(writes)); |
| 355 | 355 |
| 356 ChunkedUploadDataStream upload_stream(0); | 356 ChunkedUploadDataStream upload_stream(0); |
| 357 const int kFirstChunkSize = kUploadDataSize/2; | 357 const int kFirstChunkSize = kUploadDataSize/2; |
| 358 upload_stream.AppendData(kUploadData, kFirstChunkSize, false); | 358 upload_stream.AppendData(kUploadData, kFirstChunkSize, false); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 395 // This unittest tests the request callback is properly called and handled. | 395 // This unittest tests the request callback is properly called and handled. |
| 396 TEST_F(SpdyHttpStreamTest, SendChunkedPostLastEmpty) { | 396 TEST_F(SpdyHttpStreamTest, SendChunkedPostLastEmpty) { |
| 397 SpdySerializedFrame req(spdy_util_.ConstructChunkedSpdyPost(nullptr, 0)); | 397 SpdySerializedFrame req(spdy_util_.ConstructChunkedSpdyPost(nullptr, 0)); |
| 398 SpdySerializedFrame chunk( | 398 SpdySerializedFrame chunk( |
| 399 spdy_util_.ConstructSpdyDataFrame(1, nullptr, 0, true)); | 399 spdy_util_.ConstructSpdyDataFrame(1, nullptr, 0, true)); |
| 400 MockWrite writes[] = { | 400 MockWrite writes[] = { |
| 401 CreateMockWrite(req, 0), // request | 401 CreateMockWrite(req, 0), // request |
| 402 CreateMockWrite(chunk, 1), | 402 CreateMockWrite(chunk, 1), |
| 403 }; | 403 }; |
| 404 | 404 |
| 405 SpdySerializedFrame resp(spdy_util_.ConstructSpdyPostSynReply(nullptr, 0)); | 405 SpdySerializedFrame resp(spdy_util_.ConstructSpdyPostReply(nullptr, 0)); |
| 406 MockRead reads[] = { | 406 MockRead reads[] = { |
| 407 CreateMockRead(resp, 2), CreateMockRead(chunk, 3), | 407 CreateMockRead(resp, 2), CreateMockRead(chunk, 3), |
| 408 MockRead(SYNCHRONOUS, 0, 4) // EOF | 408 MockRead(SYNCHRONOUS, 0, 4) // EOF |
| 409 }; | 409 }; |
| 410 | 410 |
| 411 InitSession(reads, arraysize(reads), writes, arraysize(writes)); | 411 InitSession(reads, arraysize(reads), writes, arraysize(writes)); |
| 412 | 412 |
| 413 ChunkedUploadDataStream upload_stream(0); | 413 ChunkedUploadDataStream upload_stream(0); |
| 414 upload_stream.AppendData(nullptr, 0, true); | 414 upload_stream.AppendData(nullptr, 0, true); |
| 415 | 415 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 446 TEST_F(SpdyHttpStreamTest, ConnectionClosedDuringChunkedPost) { | 446 TEST_F(SpdyHttpStreamTest, ConnectionClosedDuringChunkedPost) { |
| 447 SpdySerializedFrame req(spdy_util_.ConstructChunkedSpdyPost(nullptr, 0)); | 447 SpdySerializedFrame req(spdy_util_.ConstructChunkedSpdyPost(nullptr, 0)); |
| 448 SpdySerializedFrame body(spdy_util_.ConstructSpdyDataFrame(1, kUploadData, | 448 SpdySerializedFrame body(spdy_util_.ConstructSpdyDataFrame(1, kUploadData, |
| 449 kUploadDataSize, | 449 kUploadDataSize, |
| 450 /*fin=*/false)); | 450 /*fin=*/false)); |
| 451 MockWrite writes[] = { | 451 MockWrite writes[] = { |
| 452 CreateMockWrite(req, 0), // Request | 452 CreateMockWrite(req, 0), // Request |
| 453 CreateMockWrite(body, 1) // First POST upload frame | 453 CreateMockWrite(body, 1) // First POST upload frame |
| 454 }; | 454 }; |
| 455 | 455 |
| 456 SpdySerializedFrame resp(spdy_util_.ConstructSpdyPostSynReply(nullptr, 0)); | 456 SpdySerializedFrame resp(spdy_util_.ConstructSpdyPostReply(nullptr, 0)); |
| 457 MockRead reads[] = { | 457 MockRead reads[] = { |
| 458 MockRead(ASYNC, ERR_CONNECTION_CLOSED, 2) // Server hangs up early. | 458 MockRead(ASYNC, ERR_CONNECTION_CLOSED, 2) // Server hangs up early. |
| 459 }; | 459 }; |
| 460 | 460 |
| 461 InitSession(reads, arraysize(reads), writes, arraysize(writes)); | 461 InitSession(reads, arraysize(reads), writes, arraysize(writes)); |
| 462 | 462 |
| 463 ChunkedUploadDataStream upload_stream(0); | 463 ChunkedUploadDataStream upload_stream(0); |
| 464 // Append first chunk. | 464 // Append first chunk. |
| 465 upload_stream.AppendData(kUploadData, kUploadDataSize, false); | 465 upload_stream.AppendData(kUploadData, kUploadDataSize, false); |
| 466 | 466 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 513 SpdySerializedFrame req(spdy_util_.ConstructChunkedSpdyPost(nullptr, 0)); | 513 SpdySerializedFrame req(spdy_util_.ConstructChunkedSpdyPost(nullptr, 0)); |
| 514 SpdySerializedFrame chunk1(spdy_util_.ConstructSpdyDataFrame(1, false)); | 514 SpdySerializedFrame chunk1(spdy_util_.ConstructSpdyDataFrame(1, false)); |
| 515 SpdySerializedFrame chunk2(spdy_util_.ConstructSpdyDataFrame( | 515 SpdySerializedFrame chunk2(spdy_util_.ConstructSpdyDataFrame( |
| 516 1, kUploadData1, kUploadData1Size, false)); | 516 1, kUploadData1, kUploadData1Size, false)); |
| 517 SpdySerializedFrame chunk3(spdy_util_.ConstructSpdyDataFrame(1, true)); | 517 SpdySerializedFrame chunk3(spdy_util_.ConstructSpdyDataFrame(1, true)); |
| 518 MockWrite writes[] = { | 518 MockWrite writes[] = { |
| 519 CreateMockWrite(req, 0), | 519 CreateMockWrite(req, 0), |
| 520 CreateMockWrite(chunk1, 1), // POST upload frames | 520 CreateMockWrite(chunk1, 1), // POST upload frames |
| 521 CreateMockWrite(chunk2, 2), CreateMockWrite(chunk3, 3), | 521 CreateMockWrite(chunk2, 2), CreateMockWrite(chunk3, 3), |
| 522 }; | 522 }; |
| 523 SpdySerializedFrame resp(spdy_util_.ConstructSpdyPostSynReply(nullptr, 0)); | 523 SpdySerializedFrame resp(spdy_util_.ConstructSpdyPostReply(nullptr, 0)); |
| 524 MockRead reads[] = { | 524 MockRead reads[] = { |
| 525 CreateMockRead(resp, 4), CreateMockRead(chunk1, 5), | 525 CreateMockRead(resp, 4), CreateMockRead(chunk1, 5), |
| 526 CreateMockRead(chunk2, 6), CreateMockRead(chunk3, 7), | 526 CreateMockRead(chunk2, 6), CreateMockRead(chunk3, 7), |
| 527 MockRead(ASYNC, 0, 8) // EOF | 527 MockRead(ASYNC, 0, 8) // EOF |
| 528 }; | 528 }; |
| 529 | 529 |
| 530 InitSession(reads, arraysize(reads), writes, arraysize(writes)); | 530 InitSession(reads, arraysize(reads), writes, arraysize(writes)); |
| 531 | 531 |
| 532 ChunkedUploadDataStream upload_stream(0); | 532 ChunkedUploadDataStream upload_stream(0); |
| 533 | 533 |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 606 // frame when uploading a chunked data stream. | 606 // frame when uploading a chunked data stream. |
| 607 TEST_F(SpdyHttpStreamTest, DelayedSendChunkedPostWithEmptyFinalDataFrame) { | 607 TEST_F(SpdyHttpStreamTest, DelayedSendChunkedPostWithEmptyFinalDataFrame) { |
| 608 SpdySerializedFrame req(spdy_util_.ConstructChunkedSpdyPost(nullptr, 0)); | 608 SpdySerializedFrame req(spdy_util_.ConstructChunkedSpdyPost(nullptr, 0)); |
| 609 SpdySerializedFrame chunk1(spdy_util_.ConstructSpdyDataFrame(1, false)); | 609 SpdySerializedFrame chunk1(spdy_util_.ConstructSpdyDataFrame(1, false)); |
| 610 SpdySerializedFrame chunk2(spdy_util_.ConstructSpdyDataFrame(1, "", 0, true)); | 610 SpdySerializedFrame chunk2(spdy_util_.ConstructSpdyDataFrame(1, "", 0, true)); |
| 611 MockWrite writes[] = { | 611 MockWrite writes[] = { |
| 612 CreateMockWrite(req, 0), | 612 CreateMockWrite(req, 0), |
| 613 CreateMockWrite(chunk1, 1), // POST upload frames | 613 CreateMockWrite(chunk1, 1), // POST upload frames |
| 614 CreateMockWrite(chunk2, 2), | 614 CreateMockWrite(chunk2, 2), |
| 615 }; | 615 }; |
| 616 SpdySerializedFrame resp(spdy_util_.ConstructSpdyPostSynReply(nullptr, 0)); | 616 SpdySerializedFrame resp(spdy_util_.ConstructSpdyPostReply(nullptr, 0)); |
| 617 MockRead reads[] = { | 617 MockRead reads[] = { |
| 618 CreateMockRead(resp, 3), CreateMockRead(chunk1, 4), | 618 CreateMockRead(resp, 3), CreateMockRead(chunk1, 4), |
| 619 CreateMockRead(chunk2, 5), MockRead(ASYNC, 0, 6) // EOF | 619 CreateMockRead(chunk2, 5), MockRead(ASYNC, 0, 6) // EOF |
| 620 }; | 620 }; |
| 621 | 621 |
| 622 InitSession(reads, arraysize(reads), writes, arraysize(writes)); | 622 InitSession(reads, arraysize(reads), writes, arraysize(writes)); |
| 623 | 623 |
| 624 ChunkedUploadDataStream upload_stream(0); | 624 ChunkedUploadDataStream upload_stream(0); |
| 625 | 625 |
| 626 HttpRequestInfo request; | 626 HttpRequestInfo request; |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 687 } | 687 } |
| 688 | 688 |
| 689 // Test that the SpdyStream state machine handles a chunked upload with no | 689 // Test that the SpdyStream state machine handles a chunked upload with no |
| 690 // payload. Unclear if this is a case worth supporting. | 690 // payload. Unclear if this is a case worth supporting. |
| 691 TEST_F(SpdyHttpStreamTest, ChunkedPostWithEmptyPayload) { | 691 TEST_F(SpdyHttpStreamTest, ChunkedPostWithEmptyPayload) { |
| 692 SpdySerializedFrame req(spdy_util_.ConstructChunkedSpdyPost(nullptr, 0)); | 692 SpdySerializedFrame req(spdy_util_.ConstructChunkedSpdyPost(nullptr, 0)); |
| 693 SpdySerializedFrame chunk(spdy_util_.ConstructSpdyDataFrame(1, "", 0, true)); | 693 SpdySerializedFrame chunk(spdy_util_.ConstructSpdyDataFrame(1, "", 0, true)); |
| 694 MockWrite writes[] = { | 694 MockWrite writes[] = { |
| 695 CreateMockWrite(req, 0), CreateMockWrite(chunk, 1), | 695 CreateMockWrite(req, 0), CreateMockWrite(chunk, 1), |
| 696 }; | 696 }; |
| 697 SpdySerializedFrame resp(spdy_util_.ConstructSpdyPostSynReply(nullptr, 0)); | 697 SpdySerializedFrame resp(spdy_util_.ConstructSpdyPostReply(nullptr, 0)); |
| 698 MockRead reads[] = { | 698 MockRead reads[] = { |
| 699 CreateMockRead(resp, 2), CreateMockRead(chunk, 3), | 699 CreateMockRead(resp, 2), CreateMockRead(chunk, 3), |
| 700 MockRead(ASYNC, 0, 4) // EOF | 700 MockRead(ASYNC, 0, 4) // EOF |
| 701 }; | 701 }; |
| 702 | 702 |
| 703 InitSession(reads, arraysize(reads), writes, arraysize(writes)); | 703 InitSession(reads, arraysize(reads), writes, arraysize(writes)); |
| 704 | 704 |
| 705 ChunkedUploadDataStream upload_stream(0); | 705 ChunkedUploadDataStream upload_stream(0); |
| 706 | 706 |
| 707 HttpRequestInfo request; | 707 HttpRequestInfo request; |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 751 } | 751 } |
| 752 | 752 |
| 753 // Test case for bug: http://code.google.com/p/chromium/issues/detail?id=50058 | 753 // Test case for bug: http://code.google.com/p/chromium/issues/detail?id=50058 |
| 754 TEST_F(SpdyHttpStreamTest, SpdyURLTest) { | 754 TEST_F(SpdyHttpStreamTest, SpdyURLTest) { |
| 755 const char* const full_url = "http://www.example.org/foo?query=what#anchor"; | 755 const char* const full_url = "http://www.example.org/foo?query=what#anchor"; |
| 756 const char* const base_url = "http://www.example.org/foo?query=what"; | 756 const char* const base_url = "http://www.example.org/foo?query=what"; |
| 757 SpdySerializedFrame req(spdy_util_.ConstructSpdyGet(base_url, 1, LOWEST)); | 757 SpdySerializedFrame req(spdy_util_.ConstructSpdyGet(base_url, 1, LOWEST)); |
| 758 MockWrite writes[] = { | 758 MockWrite writes[] = { |
| 759 CreateMockWrite(req, 0), | 759 CreateMockWrite(req, 0), |
| 760 }; | 760 }; |
| 761 SpdySerializedFrame resp(spdy_util_.ConstructSpdyGetSynReply(nullptr, 0, 1)); | 761 SpdySerializedFrame resp(spdy_util_.ConstructSpdyGetReply(nullptr, 0, 1)); |
| 762 MockRead reads[] = { | 762 MockRead reads[] = { |
| 763 CreateMockRead(resp, 1), MockRead(SYNCHRONOUS, 0, 2) // EOF | 763 CreateMockRead(resp, 1), MockRead(SYNCHRONOUS, 0, 2) // EOF |
| 764 }; | 764 }; |
| 765 | 765 |
| 766 InitSession(reads, arraysize(reads), writes, arraysize(writes)); | 766 InitSession(reads, arraysize(reads), writes, arraysize(writes)); |
| 767 | 767 |
| 768 HttpRequestInfo request; | 768 HttpRequestInfo request; |
| 769 request.method = "GET"; | 769 request.method = "GET"; |
| 770 request.url = GURL(full_url); | 770 request.url = GURL(full_url); |
| 771 TestCompletionCallback callback; | 771 TestCompletionCallback callback; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 795 } | 795 } |
| 796 | 796 |
| 797 // Test the receipt of a WINDOW_UPDATE frame while waiting for a chunk to be | 797 // Test the receipt of a WINDOW_UPDATE frame while waiting for a chunk to be |
| 798 // made available is handled correctly. | 798 // made available is handled correctly. |
| 799 TEST_F(SpdyHttpStreamTest, DelayedSendChunkedPostWithWindowUpdate) { | 799 TEST_F(SpdyHttpStreamTest, DelayedSendChunkedPostWithWindowUpdate) { |
| 800 SpdySerializedFrame req(spdy_util_.ConstructChunkedSpdyPost(nullptr, 0)); | 800 SpdySerializedFrame req(spdy_util_.ConstructChunkedSpdyPost(nullptr, 0)); |
| 801 SpdySerializedFrame chunk1(spdy_util_.ConstructSpdyDataFrame(1, true)); | 801 SpdySerializedFrame chunk1(spdy_util_.ConstructSpdyDataFrame(1, true)); |
| 802 MockWrite writes[] = { | 802 MockWrite writes[] = { |
| 803 CreateMockWrite(req, 0), CreateMockWrite(chunk1, 1), | 803 CreateMockWrite(req, 0), CreateMockWrite(chunk1, 1), |
| 804 }; | 804 }; |
| 805 SpdySerializedFrame resp(spdy_util_.ConstructSpdyPostSynReply(nullptr, 0)); | 805 SpdySerializedFrame resp(spdy_util_.ConstructSpdyPostReply(nullptr, 0)); |
| 806 SpdySerializedFrame window_update( | 806 SpdySerializedFrame window_update( |
| 807 spdy_util_.ConstructSpdyWindowUpdate(1, kUploadDataSize)); | 807 spdy_util_.ConstructSpdyWindowUpdate(1, kUploadDataSize)); |
| 808 MockRead reads[] = { | 808 MockRead reads[] = { |
| 809 CreateMockRead(window_update, 2), MockRead(ASYNC, ERR_IO_PENDING, 3), | 809 CreateMockRead(window_update, 2), MockRead(ASYNC, ERR_IO_PENDING, 3), |
| 810 CreateMockRead(resp, 4), CreateMockRead(chunk1, 5), | 810 CreateMockRead(resp, 4), CreateMockRead(chunk1, 5), |
| 811 MockRead(ASYNC, 0, 6) // EOF | 811 MockRead(ASYNC, 0, 6) // EOF |
| 812 }; | 812 }; |
| 813 | 813 |
| 814 InitSession(reads, arraysize(reads), writes, arraysize(writes)); | 814 InitSession(reads, arraysize(reads), writes, arraysize(writes)); |
| 815 | 815 |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 897 // The failure is a reading error in this case caused by | 897 // The failure is a reading error in this case caused by |
| 898 // UploadDataStream::Read(). | 898 // UploadDataStream::Read(). |
| 899 SpdySerializedFrame rst_frame( | 899 SpdySerializedFrame rst_frame( |
| 900 spdy_util_.ConstructSpdyRstStream(1, RST_STREAM_INTERNAL_ERROR)); | 900 spdy_util_.ConstructSpdyRstStream(1, RST_STREAM_INTERNAL_ERROR)); |
| 901 | 901 |
| 902 MockWrite writes[] = { | 902 MockWrite writes[] = { |
| 903 CreateMockWrite(req, 0, SYNCHRONOUS), // Request | 903 CreateMockWrite(req, 0, SYNCHRONOUS), // Request |
| 904 CreateMockWrite(rst_frame, 1, SYNCHRONOUS) // Reset frame | 904 CreateMockWrite(rst_frame, 1, SYNCHRONOUS) // Reset frame |
| 905 }; | 905 }; |
| 906 | 906 |
| 907 SpdySerializedFrame resp(spdy_util_.ConstructSpdyPostSynReply(nullptr, 0)); | 907 SpdySerializedFrame resp(spdy_util_.ConstructSpdyPostReply(nullptr, 0)); |
| 908 | 908 |
| 909 MockRead reads[] = { | 909 MockRead reads[] = { |
| 910 CreateMockRead(resp, 2), MockRead(SYNCHRONOUS, 0, 3), | 910 CreateMockRead(resp, 2), MockRead(SYNCHRONOUS, 0, 3), |
| 911 }; | 911 }; |
| 912 | 912 |
| 913 InitSession(reads, arraysize(reads), writes, arraysize(writes)); | 913 InitSession(reads, arraysize(reads), writes, arraysize(writes)); |
| 914 | 914 |
| 915 ReadErrorUploadDataStream upload_data_stream( | 915 ReadErrorUploadDataStream upload_data_stream( |
| 916 ReadErrorUploadDataStream::FailureMode::SYNC); | 916 ReadErrorUploadDataStream::FailureMode::SYNC); |
| 917 ASSERT_THAT(upload_data_stream.Init(TestCompletionCallback().callback()), | 917 ASSERT_THAT(upload_data_stream.Init(TestCompletionCallback().callback()), |
| (...skipping 27 matching lines...) Expand all Loading... |
| 945 // The failure is a reading error in this case caused by | 945 // The failure is a reading error in this case caused by |
| 946 // UploadDataStream::Read(). | 946 // UploadDataStream::Read(). |
| 947 SpdySerializedFrame rst_frame( | 947 SpdySerializedFrame rst_frame( |
| 948 spdy_util_.ConstructSpdyRstStream(1, RST_STREAM_INTERNAL_ERROR)); | 948 spdy_util_.ConstructSpdyRstStream(1, RST_STREAM_INTERNAL_ERROR)); |
| 949 | 949 |
| 950 MockWrite writes[] = { | 950 MockWrite writes[] = { |
| 951 CreateMockWrite(req, 0), // Request | 951 CreateMockWrite(req, 0), // Request |
| 952 CreateMockWrite(rst_frame, 1) // Reset frame | 952 CreateMockWrite(rst_frame, 1) // Reset frame |
| 953 }; | 953 }; |
| 954 | 954 |
| 955 SpdySerializedFrame resp(spdy_util_.ConstructSpdyPostSynReply(nullptr, 0)); | 955 SpdySerializedFrame resp(spdy_util_.ConstructSpdyPostReply(nullptr, 0)); |
| 956 | 956 |
| 957 MockRead reads[] = { | 957 MockRead reads[] = { |
| 958 MockRead(ASYNC, 0, 2), | 958 MockRead(ASYNC, 0, 2), |
| 959 }; | 959 }; |
| 960 | 960 |
| 961 InitSession(reads, arraysize(reads), writes, arraysize(writes)); | 961 InitSession(reads, arraysize(reads), writes, arraysize(writes)); |
| 962 | 962 |
| 963 ReadErrorUploadDataStream upload_data_stream( | 963 ReadErrorUploadDataStream upload_data_stream( |
| 964 ReadErrorUploadDataStream::FailureMode::ASYNC); | 964 ReadErrorUploadDataStream::FailureMode::ASYNC); |
| 965 ASSERT_THAT(upload_data_stream.Init(TestCompletionCallback().callback()), | 965 ASSERT_THAT(upload_data_stream.Init(TestCompletionCallback().callback()), |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1027 // The callback cancels |http_stream|. | 1027 // The callback cancels |http_stream|. |
| 1028 EXPECT_THAT(callback.WaitForResult(), IsOk()); | 1028 EXPECT_THAT(callback.WaitForResult(), IsOk()); |
| 1029 | 1029 |
| 1030 EXPECT_FALSE(HasSpdySession(http_session_->spdy_session_pool(), key_)); | 1030 EXPECT_FALSE(HasSpdySession(http_session_->spdy_session_pool(), key_)); |
| 1031 } | 1031 } |
| 1032 | 1032 |
| 1033 // TODO(willchan): Write a longer test for SpdyStream that exercises all | 1033 // TODO(willchan): Write a longer test for SpdyStream that exercises all |
| 1034 // methods. | 1034 // methods. |
| 1035 | 1035 |
| 1036 } // namespace net | 1036 } // namespace net |
| OLD | NEW |