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 #include <string> | 10 #include <string> |
11 | 11 |
12 #include "base/run_loop.h" | 12 #include "base/run_loop.h" |
13 #include "base/stl_util.h" | 13 #include "base/stl_util.h" |
14 #include "base/threading/thread_task_runner_handle.h" | 14 #include "base/threading/thread_task_runner_handle.h" |
15 #include "crypto/ec_private_key.h" | 15 #include "crypto/ec_private_key.h" |
16 #include "crypto/ec_signature_creator.h" | 16 #include "crypto/ec_signature_creator.h" |
17 #include "crypto/signature_creator.h" | 17 #include "crypto/signature_creator.h" |
18 #include "net/base/chunked_upload_data_stream.h" | 18 #include "net/base/chunked_upload_data_stream.h" |
19 #include "net/base/load_timing_info.h" | 19 #include "net/base/load_timing_info.h" |
20 #include "net/base/load_timing_info_test_util.h" | 20 #include "net/base/load_timing_info_test_util.h" |
21 #include "net/base/test_completion_callback.h" | 21 #include "net/base/test_completion_callback.h" |
22 #include "net/cert/asn1_util.h" | 22 #include "net/cert/asn1_util.h" |
23 #include "net/http/http_request_info.h" | 23 #include "net/http/http_request_info.h" |
24 #include "net/http/http_response_headers.h" | 24 #include "net/http/http_response_headers.h" |
25 #include "net/http/http_response_info.h" | 25 #include "net/http/http_response_info.h" |
26 #include "net/log/net_log_source.h" | |
27 #include "net/log/net_log_with_source.h" | 26 #include "net/log/net_log_with_source.h" |
28 #include "net/log/test_net_log.h" | 27 #include "net/log/test_net_log.h" |
29 #include "net/socket/socket_test_util.h" | 28 #include "net/socket/socket_test_util.h" |
30 #include "net/spdy/spdy_http_utils.h" | 29 #include "net/spdy/spdy_http_utils.h" |
31 #include "net/spdy/spdy_session.h" | 30 #include "net/spdy/spdy_session.h" |
32 #include "net/spdy/spdy_test_util_common.h" | 31 #include "net/spdy/spdy_test_util_common.h" |
33 #include "net/ssl/default_channel_id_store.h" | 32 #include "net/ssl/default_channel_id_store.h" |
34 #include "net/test/cert_test_util.h" | 33 #include "net/test/cert_test_util.h" |
35 #include "net/test/gtest_util.h" | 34 #include "net/test/gtest_util.h" |
36 #include "net/test/test_data_directory.h" | 35 #include "net/test/test_data_directory.h" |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 InitSession(reads, arraysize(reads), writes, arraysize(writes)); | 195 InitSession(reads, arraysize(reads), writes, arraysize(writes)); |
197 | 196 |
198 HttpRequestInfo request; | 197 HttpRequestInfo request; |
199 request.method = "GET"; | 198 request.method = "GET"; |
200 request.url = url_; | 199 request.url = url_; |
201 TestCompletionCallback callback; | 200 TestCompletionCallback callback; |
202 HttpResponseInfo response; | 201 HttpResponseInfo response; |
203 HttpRequestHeaders headers; | 202 HttpRequestHeaders headers; |
204 NetLogWithSource net_log; | 203 NetLogWithSource net_log; |
205 std::unique_ptr<SpdyHttpStream> http_stream( | 204 std::unique_ptr<SpdyHttpStream> http_stream( |
206 new SpdyHttpStream(session_, true)); | 205 new SpdyHttpStream(session_, true, net_log.source())); |
207 // Make sure getting load timing information the stream early does not crash. | 206 // Make sure getting load timing information the stream early does not crash. |
208 LoadTimingInfo load_timing_info; | 207 LoadTimingInfo load_timing_info; |
209 EXPECT_FALSE(http_stream->GetLoadTimingInfo(&load_timing_info)); | 208 EXPECT_FALSE(http_stream->GetLoadTimingInfo(&load_timing_info)); |
210 | 209 |
211 ASSERT_THAT(http_stream->InitializeStream(&request, DEFAULT_PRIORITY, net_log, | 210 ASSERT_THAT(http_stream->InitializeStream(&request, DEFAULT_PRIORITY, net_log, |
212 CompletionCallback()), | 211 CompletionCallback()), |
213 IsOk()); | 212 IsOk()); |
214 EXPECT_FALSE(http_stream->GetLoadTimingInfo(&load_timing_info)); | 213 EXPECT_FALSE(http_stream->GetLoadTimingInfo(&load_timing_info)); |
215 | 214 |
216 EXPECT_THAT(http_stream->SendRequest(headers, &response, callback.callback()), | 215 EXPECT_THAT(http_stream->SendRequest(headers, &response, callback.callback()), |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
257 }; | 256 }; |
258 | 257 |
259 InitSession(reads, arraysize(reads), writes, arraysize(writes)); | 258 InitSession(reads, arraysize(reads), writes, arraysize(writes)); |
260 | 259 |
261 HttpRequestInfo request1; | 260 HttpRequestInfo request1; |
262 request1.method = "GET"; | 261 request1.method = "GET"; |
263 request1.url = url_; | 262 request1.url = url_; |
264 TestCompletionCallback callback1; | 263 TestCompletionCallback callback1; |
265 HttpResponseInfo response1; | 264 HttpResponseInfo response1; |
266 HttpRequestHeaders headers1; | 265 HttpRequestHeaders headers1; |
| 266 NetLogWithSource net_log; |
267 std::unique_ptr<SpdyHttpStream> http_stream1( | 267 std::unique_ptr<SpdyHttpStream> http_stream1( |
268 new SpdyHttpStream(session_, true)); | 268 new SpdyHttpStream(session_, true, net_log.source())); |
269 | 269 |
270 HttpRequestInfo request2; | 270 HttpRequestInfo request2; |
271 request2.method = "GET"; | 271 request2.method = "GET"; |
272 request2.url = url_; | 272 request2.url = url_; |
273 TestCompletionCallback callback2; | 273 TestCompletionCallback callback2; |
274 HttpResponseInfo response2; | 274 HttpResponseInfo response2; |
275 HttpRequestHeaders headers2; | 275 HttpRequestHeaders headers2; |
276 std::unique_ptr<SpdyHttpStream> http_stream2( | 276 std::unique_ptr<SpdyHttpStream> http_stream2( |
277 new SpdyHttpStream(session_, true)); | 277 new SpdyHttpStream(session_, true, net_log.source())); |
278 | 278 |
279 // First write. | 279 // First write. |
280 ASSERT_THAT( | 280 ASSERT_THAT(http_stream1->InitializeStream(&request1, DEFAULT_PRIORITY, |
281 http_stream1->InitializeStream(&request1, DEFAULT_PRIORITY, | 281 net_log, CompletionCallback()), |
282 NetLogWithSource(), CompletionCallback()), | 282 IsOk()); |
283 IsOk()); | |
284 EXPECT_THAT( | 283 EXPECT_THAT( |
285 http_stream1->SendRequest(headers1, &response1, callback1.callback()), | 284 http_stream1->SendRequest(headers1, &response1, callback1.callback()), |
286 IsError(ERR_IO_PENDING)); | 285 IsError(ERR_IO_PENDING)); |
287 EXPECT_TRUE(HasSpdySession(http_session_->spdy_session_pool(), key_)); | 286 EXPECT_TRUE(HasSpdySession(http_session_->spdy_session_pool(), key_)); |
288 | 287 |
289 EXPECT_LE(0, callback1.WaitForResult()); | 288 EXPECT_LE(0, callback1.WaitForResult()); |
290 | 289 |
291 TestLoadTimingNotReused(*http_stream1); | 290 TestLoadTimingNotReused(*http_stream1); |
292 LoadTimingInfo load_timing_info1; | 291 LoadTimingInfo load_timing_info1; |
293 LoadTimingInfo load_timing_info2; | 292 LoadTimingInfo load_timing_info2; |
294 EXPECT_TRUE(http_stream1->GetLoadTimingInfo(&load_timing_info1)); | 293 EXPECT_TRUE(http_stream1->GetLoadTimingInfo(&load_timing_info1)); |
295 EXPECT_FALSE(http_stream2->GetLoadTimingInfo(&load_timing_info2)); | 294 EXPECT_FALSE(http_stream2->GetLoadTimingInfo(&load_timing_info2)); |
296 | 295 |
297 // Second write. | 296 // Second write. |
298 ASSERT_THAT( | 297 ASSERT_THAT(http_stream2->InitializeStream(&request2, DEFAULT_PRIORITY, |
299 http_stream2->InitializeStream(&request2, DEFAULT_PRIORITY, | 298 net_log, CompletionCallback()), |
300 NetLogWithSource(), CompletionCallback()), | 299 IsOk()); |
301 IsOk()); | |
302 EXPECT_THAT( | 300 EXPECT_THAT( |
303 http_stream2->SendRequest(headers2, &response2, callback2.callback()), | 301 http_stream2->SendRequest(headers2, &response2, callback2.callback()), |
304 IsError(ERR_IO_PENDING)); | 302 IsError(ERR_IO_PENDING)); |
305 EXPECT_TRUE(HasSpdySession(http_session_->spdy_session_pool(), key_)); | 303 EXPECT_TRUE(HasSpdySession(http_session_->spdy_session_pool(), key_)); |
306 | 304 |
307 EXPECT_LE(0, callback2.WaitForResult()); | 305 EXPECT_LE(0, callback2.WaitForResult()); |
308 | 306 |
309 // Perform all async reads. | 307 // Perform all async reads. |
310 base::RunLoop().RunUntilIdle(); | 308 base::RunLoop().RunUntilIdle(); |
311 | 309 |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
366 request.upload_data_stream = &upload_stream; | 364 request.upload_data_stream = &upload_stream; |
367 | 365 |
368 ASSERT_THAT(upload_stream.Init(TestCompletionCallback().callback(), | 366 ASSERT_THAT(upload_stream.Init(TestCompletionCallback().callback(), |
369 NetLogWithSource()), | 367 NetLogWithSource()), |
370 IsOk()); | 368 IsOk()); |
371 | 369 |
372 TestCompletionCallback callback; | 370 TestCompletionCallback callback; |
373 HttpResponseInfo response; | 371 HttpResponseInfo response; |
374 HttpRequestHeaders headers; | 372 HttpRequestHeaders headers; |
375 NetLogWithSource net_log; | 373 NetLogWithSource net_log; |
376 SpdyHttpStream http_stream(session_, true); | 374 SpdyHttpStream http_stream(session_, true, net_log.source()); |
377 ASSERT_THAT(http_stream.InitializeStream(&request, DEFAULT_PRIORITY, net_log, | 375 ASSERT_THAT(http_stream.InitializeStream(&request, DEFAULT_PRIORITY, net_log, |
378 CompletionCallback()), | 376 CompletionCallback()), |
379 IsOk()); | 377 IsOk()); |
380 | 378 |
381 EXPECT_THAT(http_stream.SendRequest(headers, &response, callback.callback()), | 379 EXPECT_THAT(http_stream.SendRequest(headers, &response, callback.callback()), |
382 IsError(ERR_IO_PENDING)); | 380 IsError(ERR_IO_PENDING)); |
383 EXPECT_TRUE(HasSpdySession(http_session_->spdy_session_pool(), key_)); | 381 EXPECT_TRUE(HasSpdySession(http_session_->spdy_session_pool(), key_)); |
384 | 382 |
385 EXPECT_THAT(callback.WaitForResult(), IsOk()); | 383 EXPECT_THAT(callback.WaitForResult(), IsOk()); |
386 | 384 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
421 request.upload_data_stream = &upload_stream; | 419 request.upload_data_stream = &upload_stream; |
422 | 420 |
423 ASSERT_THAT(upload_stream.Init(TestCompletionCallback().callback(), | 421 ASSERT_THAT(upload_stream.Init(TestCompletionCallback().callback(), |
424 NetLogWithSource()), | 422 NetLogWithSource()), |
425 IsOk()); | 423 IsOk()); |
426 | 424 |
427 TestCompletionCallback callback; | 425 TestCompletionCallback callback; |
428 HttpResponseInfo response; | 426 HttpResponseInfo response; |
429 HttpRequestHeaders headers; | 427 HttpRequestHeaders headers; |
430 NetLogWithSource net_log; | 428 NetLogWithSource net_log; |
431 SpdyHttpStream http_stream(session_, true); | 429 SpdyHttpStream http_stream(session_, true, net_log.source()); |
432 ASSERT_THAT(http_stream.InitializeStream(&request, DEFAULT_PRIORITY, net_log, | 430 ASSERT_THAT(http_stream.InitializeStream(&request, DEFAULT_PRIORITY, net_log, |
433 CompletionCallback()), | 431 CompletionCallback()), |
434 IsOk()); | 432 IsOk()); |
435 EXPECT_THAT(http_stream.SendRequest(headers, &response, callback.callback()), | 433 EXPECT_THAT(http_stream.SendRequest(headers, &response, callback.callback()), |
436 IsError(ERR_IO_PENDING)); | 434 IsError(ERR_IO_PENDING)); |
437 EXPECT_TRUE(HasSpdySession(http_session_->spdy_session_pool(), key_)); | 435 EXPECT_TRUE(HasSpdySession(http_session_->spdy_session_pool(), key_)); |
438 | 436 |
439 EXPECT_THAT(callback.WaitForResult(), IsOk()); | 437 EXPECT_THAT(callback.WaitForResult(), IsOk()); |
440 | 438 |
441 EXPECT_EQ(static_cast<int64_t>(req.size() + chunk.size()), | 439 EXPECT_EQ(static_cast<int64_t>(req.size() + chunk.size()), |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
475 request.upload_data_stream = &upload_stream; | 473 request.upload_data_stream = &upload_stream; |
476 | 474 |
477 ASSERT_THAT(upload_stream.Init(TestCompletionCallback().callback(), | 475 ASSERT_THAT(upload_stream.Init(TestCompletionCallback().callback(), |
478 NetLogWithSource()), | 476 NetLogWithSource()), |
479 IsOk()); | 477 IsOk()); |
480 | 478 |
481 TestCompletionCallback callback; | 479 TestCompletionCallback callback; |
482 HttpResponseInfo response; | 480 HttpResponseInfo response; |
483 HttpRequestHeaders headers; | 481 HttpRequestHeaders headers; |
484 NetLogWithSource net_log; | 482 NetLogWithSource net_log; |
485 SpdyHttpStream http_stream(session_, true); | 483 SpdyHttpStream http_stream(session_, true, net_log.source()); |
486 ASSERT_THAT(http_stream.InitializeStream(&request, DEFAULT_PRIORITY, net_log, | 484 ASSERT_THAT(http_stream.InitializeStream(&request, DEFAULT_PRIORITY, net_log, |
487 CompletionCallback()), | 485 CompletionCallback()), |
488 IsOk()); | 486 IsOk()); |
489 | 487 |
490 EXPECT_THAT(http_stream.SendRequest(headers, &response, callback.callback()), | 488 EXPECT_THAT(http_stream.SendRequest(headers, &response, callback.callback()), |
491 IsError(ERR_IO_PENDING)); | 489 IsError(ERR_IO_PENDING)); |
492 EXPECT_TRUE(HasSpdySession(http_session_->spdy_session_pool(), key_)); | 490 EXPECT_TRUE(HasSpdySession(http_session_->spdy_session_pool(), key_)); |
493 | 491 |
494 EXPECT_THAT(callback.WaitForResult(), IsError(ERR_CONNECTION_CLOSED)); | 492 EXPECT_THAT(callback.WaitForResult(), IsError(ERR_CONNECTION_CLOSED)); |
495 | 493 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
544 request.url = url_; | 542 request.url = url_; |
545 request.upload_data_stream = &upload_stream; | 543 request.upload_data_stream = &upload_stream; |
546 | 544 |
547 ASSERT_THAT(upload_stream.Init(TestCompletionCallback().callback(), | 545 ASSERT_THAT(upload_stream.Init(TestCompletionCallback().callback(), |
548 NetLogWithSource()), | 546 NetLogWithSource()), |
549 IsOk()); | 547 IsOk()); |
550 upload_stream.AppendData(kUploadData, kUploadDataSize, false); | 548 upload_stream.AppendData(kUploadData, kUploadDataSize, false); |
551 | 549 |
552 NetLogWithSource net_log; | 550 NetLogWithSource net_log; |
553 std::unique_ptr<SpdyHttpStream> http_stream( | 551 std::unique_ptr<SpdyHttpStream> http_stream( |
554 new SpdyHttpStream(session_, true)); | 552 new SpdyHttpStream(session_, true, net_log.source())); |
555 ASSERT_THAT(http_stream->InitializeStream(&request, DEFAULT_PRIORITY, net_log, | 553 ASSERT_THAT(http_stream->InitializeStream(&request, DEFAULT_PRIORITY, net_log, |
556 CompletionCallback()), | 554 CompletionCallback()), |
557 IsOk()); | 555 IsOk()); |
558 | 556 |
559 TestCompletionCallback callback; | 557 TestCompletionCallback callback; |
560 HttpRequestHeaders headers; | 558 HttpRequestHeaders headers; |
561 HttpResponseInfo response; | 559 HttpResponseInfo response; |
562 // This will attempt to Write() the initial request and headers, which will | 560 // This will attempt to Write() the initial request and headers, which will |
563 // complete asynchronously. | 561 // complete asynchronously. |
564 EXPECT_THAT(http_stream->SendRequest(headers, &response, callback.callback()), | 562 EXPECT_THAT(http_stream->SendRequest(headers, &response, callback.callback()), |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
639 request.url = url_; | 637 request.url = url_; |
640 request.upload_data_stream = &upload_stream; | 638 request.upload_data_stream = &upload_stream; |
641 | 639 |
642 ASSERT_THAT(upload_stream.Init(TestCompletionCallback().callback(), | 640 ASSERT_THAT(upload_stream.Init(TestCompletionCallback().callback(), |
643 NetLogWithSource()), | 641 NetLogWithSource()), |
644 IsOk()); | 642 IsOk()); |
645 upload_stream.AppendData(kUploadData, kUploadDataSize, false); | 643 upload_stream.AppendData(kUploadData, kUploadDataSize, false); |
646 | 644 |
647 NetLogWithSource net_log; | 645 NetLogWithSource net_log; |
648 std::unique_ptr<SpdyHttpStream> http_stream( | 646 std::unique_ptr<SpdyHttpStream> http_stream( |
649 new SpdyHttpStream(session_, true)); | 647 new SpdyHttpStream(session_, true, net_log.source())); |
650 ASSERT_THAT(http_stream->InitializeStream(&request, DEFAULT_PRIORITY, net_log, | 648 ASSERT_THAT(http_stream->InitializeStream(&request, DEFAULT_PRIORITY, net_log, |
651 CompletionCallback()), | 649 CompletionCallback()), |
652 IsOk()); | 650 IsOk()); |
653 | 651 |
654 TestCompletionCallback callback; | 652 TestCompletionCallback callback; |
655 HttpRequestHeaders headers; | 653 HttpRequestHeaders headers; |
656 HttpResponseInfo response; | 654 HttpResponseInfo response; |
657 // This will attempt to Write() the initial request and headers, which will | 655 // This will attempt to Write() the initial request and headers, which will |
658 // complete asynchronously. | 656 // complete asynchronously. |
659 EXPECT_THAT(http_stream->SendRequest(headers, &response, callback.callback()), | 657 EXPECT_THAT(http_stream->SendRequest(headers, &response, callback.callback()), |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
723 request.url = url_; | 721 request.url = url_; |
724 request.upload_data_stream = &upload_stream; | 722 request.upload_data_stream = &upload_stream; |
725 | 723 |
726 ASSERT_THAT(upload_stream.Init(TestCompletionCallback().callback(), | 724 ASSERT_THAT(upload_stream.Init(TestCompletionCallback().callback(), |
727 NetLogWithSource()), | 725 NetLogWithSource()), |
728 IsOk()); | 726 IsOk()); |
729 upload_stream.AppendData("", 0, true); | 727 upload_stream.AppendData("", 0, true); |
730 | 728 |
731 NetLogWithSource net_log; | 729 NetLogWithSource net_log; |
732 std::unique_ptr<SpdyHttpStream> http_stream( | 730 std::unique_ptr<SpdyHttpStream> http_stream( |
733 new SpdyHttpStream(session_, true)); | 731 new SpdyHttpStream(session_, true, net_log.source())); |
734 ASSERT_THAT(http_stream->InitializeStream(&request, DEFAULT_PRIORITY, net_log, | 732 ASSERT_THAT(http_stream->InitializeStream(&request, DEFAULT_PRIORITY, net_log, |
735 CompletionCallback()), | 733 CompletionCallback()), |
736 IsOk()); | 734 IsOk()); |
737 | 735 |
738 TestCompletionCallback callback; | 736 TestCompletionCallback callback; |
739 HttpRequestHeaders headers; | 737 HttpRequestHeaders headers; |
740 HttpResponseInfo response; | 738 HttpResponseInfo response; |
741 // This will attempt to Write() the initial request and headers, which will | 739 // This will attempt to Write() the initial request and headers, which will |
742 // complete asynchronously. | 740 // complete asynchronously. |
743 EXPECT_THAT(http_stream->SendRequest(headers, &response, callback.callback()), | 741 EXPECT_THAT(http_stream->SendRequest(headers, &response, callback.callback()), |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
783 InitSession(reads, arraysize(reads), writes, arraysize(writes)); | 781 InitSession(reads, arraysize(reads), writes, arraysize(writes)); |
784 | 782 |
785 HttpRequestInfo request; | 783 HttpRequestInfo request; |
786 request.method = "GET"; | 784 request.method = "GET"; |
787 request.url = GURL(full_url); | 785 request.url = GURL(full_url); |
788 TestCompletionCallback callback; | 786 TestCompletionCallback callback; |
789 HttpResponseInfo response; | 787 HttpResponseInfo response; |
790 HttpRequestHeaders headers; | 788 HttpRequestHeaders headers; |
791 NetLogWithSource net_log; | 789 NetLogWithSource net_log; |
792 std::unique_ptr<SpdyHttpStream> http_stream( | 790 std::unique_ptr<SpdyHttpStream> http_stream( |
793 new SpdyHttpStream(session_, true)); | 791 new SpdyHttpStream(session_, true, net_log.source())); |
794 ASSERT_THAT(http_stream->InitializeStream(&request, DEFAULT_PRIORITY, net_log, | 792 ASSERT_THAT(http_stream->InitializeStream(&request, DEFAULT_PRIORITY, net_log, |
795 CompletionCallback()), | 793 CompletionCallback()), |
796 IsOk()); | 794 IsOk()); |
797 | 795 |
798 EXPECT_THAT(http_stream->SendRequest(headers, &response, callback.callback()), | 796 EXPECT_THAT(http_stream->SendRequest(headers, &response, callback.callback()), |
799 IsError(ERR_IO_PENDING)); | 797 IsError(ERR_IO_PENDING)); |
800 | 798 |
801 EXPECT_EQ(base_url, http_stream->stream()->GetUrlFromHeaders().spec()); | 799 EXPECT_EQ(base_url, http_stream->stream()->GetUrlFromHeaders().spec()); |
802 | 800 |
803 callback.WaitForResult(); | 801 callback.WaitForResult(); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
836 request.method = "POST"; | 834 request.method = "POST"; |
837 request.url = url_; | 835 request.url = url_; |
838 request.upload_data_stream = &upload_stream; | 836 request.upload_data_stream = &upload_stream; |
839 | 837 |
840 ASSERT_THAT(upload_stream.Init(TestCompletionCallback().callback(), | 838 ASSERT_THAT(upload_stream.Init(TestCompletionCallback().callback(), |
841 NetLogWithSource()), | 839 NetLogWithSource()), |
842 IsOk()); | 840 IsOk()); |
843 | 841 |
844 NetLogWithSource net_log; | 842 NetLogWithSource net_log; |
845 std::unique_ptr<SpdyHttpStream> http_stream( | 843 std::unique_ptr<SpdyHttpStream> http_stream( |
846 new SpdyHttpStream(session_, true)); | 844 new SpdyHttpStream(session_, true, net_log.source())); |
847 ASSERT_THAT(http_stream->InitializeStream(&request, DEFAULT_PRIORITY, net_log, | 845 ASSERT_THAT(http_stream->InitializeStream(&request, DEFAULT_PRIORITY, net_log, |
848 CompletionCallback()), | 846 CompletionCallback()), |
849 IsOk()); | 847 IsOk()); |
850 | 848 |
851 HttpRequestHeaders headers; | 849 HttpRequestHeaders headers; |
852 HttpResponseInfo response; | 850 HttpResponseInfo response; |
853 // This will attempt to Write() the initial request and headers, which will | 851 // This will attempt to Write() the initial request and headers, which will |
854 // complete asynchronously. | 852 // complete asynchronously. |
855 TestCompletionCallback callback; | 853 TestCompletionCallback callback; |
856 EXPECT_THAT(http_stream->SendRequest(headers, &response, callback.callback()), | 854 EXPECT_THAT(http_stream->SendRequest(headers, &response, callback.callback()), |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
940 | 938 |
941 HttpRequestInfo request; | 939 HttpRequestInfo request; |
942 request.method = "POST"; | 940 request.method = "POST"; |
943 request.url = url_; | 941 request.url = url_; |
944 request.upload_data_stream = &upload_data_stream; | 942 request.upload_data_stream = &upload_data_stream; |
945 | 943 |
946 TestCompletionCallback callback; | 944 TestCompletionCallback callback; |
947 HttpResponseInfo response; | 945 HttpResponseInfo response; |
948 HttpRequestHeaders headers; | 946 HttpRequestHeaders headers; |
949 NetLogWithSource net_log; | 947 NetLogWithSource net_log; |
950 SpdyHttpStream http_stream(session_, true); | 948 SpdyHttpStream http_stream(session_, true, net_log.source()); |
951 ASSERT_THAT(http_stream.InitializeStream(&request, DEFAULT_PRIORITY, net_log, | 949 ASSERT_THAT(http_stream.InitializeStream(&request, DEFAULT_PRIORITY, net_log, |
952 CompletionCallback()), | 950 CompletionCallback()), |
953 IsOk()); | 951 IsOk()); |
954 | 952 |
955 int result = http_stream.SendRequest(headers, &response, callback.callback()); | 953 int result = http_stream.SendRequest(headers, &response, callback.callback()); |
956 EXPECT_THAT(callback.GetResult(result), IsError(ERR_FAILED)); | 954 EXPECT_THAT(callback.GetResult(result), IsError(ERR_FAILED)); |
957 | 955 |
958 // Run posted SpdyHttpStream::ResetStreamInternal() task. | 956 // Run posted SpdyHttpStream::ResetStreamInternal() task. |
959 base::RunLoop().RunUntilIdle(); | 957 base::RunLoop().RunUntilIdle(); |
960 | 958 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
993 | 991 |
994 HttpRequestInfo request; | 992 HttpRequestInfo request; |
995 request.method = "POST"; | 993 request.method = "POST"; |
996 request.url = url_; | 994 request.url = url_; |
997 request.upload_data_stream = &upload_data_stream; | 995 request.upload_data_stream = &upload_data_stream; |
998 | 996 |
999 TestCompletionCallback callback; | 997 TestCompletionCallback callback; |
1000 HttpResponseInfo response; | 998 HttpResponseInfo response; |
1001 HttpRequestHeaders headers; | 999 HttpRequestHeaders headers; |
1002 NetLogWithSource net_log; | 1000 NetLogWithSource net_log; |
1003 SpdyHttpStream http_stream(session_, true); | 1001 SpdyHttpStream http_stream(session_, true, net_log.source()); |
1004 ASSERT_THAT(http_stream.InitializeStream(&request, DEFAULT_PRIORITY, net_log, | 1002 ASSERT_THAT(http_stream.InitializeStream(&request, DEFAULT_PRIORITY, net_log, |
1005 CompletionCallback()), | 1003 CompletionCallback()), |
1006 IsOk()); | 1004 IsOk()); |
1007 | 1005 |
1008 int result = http_stream.SendRequest(headers, &response, callback.callback()); | 1006 int result = http_stream.SendRequest(headers, &response, callback.callback()); |
1009 EXPECT_THAT(result, IsError(ERR_IO_PENDING)); | 1007 EXPECT_THAT(result, IsError(ERR_IO_PENDING)); |
1010 EXPECT_THAT(callback.GetResult(result), IsError(ERR_FAILED)); | 1008 EXPECT_THAT(callback.GetResult(result), IsError(ERR_FAILED)); |
1011 | 1009 |
1012 // Run posted SpdyHttpStream::ResetStreamInternal() task. | 1010 // Run posted SpdyHttpStream::ResetStreamInternal() task. |
1013 base::RunLoop().RunUntilIdle(); | 1011 base::RunLoop().RunUntilIdle(); |
(...skipping 21 matching lines...) Expand all Loading... |
1035 ChunkedUploadDataStream upload_stream(0); | 1033 ChunkedUploadDataStream upload_stream(0); |
1036 request.upload_data_stream = &upload_stream; | 1034 request.upload_data_stream = &upload_stream; |
1037 | 1035 |
1038 TestCompletionCallback upload_callback; | 1036 TestCompletionCallback upload_callback; |
1039 ASSERT_THAT( | 1037 ASSERT_THAT( |
1040 upload_stream.Init(upload_callback.callback(), NetLogWithSource()), | 1038 upload_stream.Init(upload_callback.callback(), NetLogWithSource()), |
1041 IsOk()); | 1039 IsOk()); |
1042 upload_stream.AppendData("", 0, true); | 1040 upload_stream.AppendData("", 0, true); |
1043 | 1041 |
1044 NetLogWithSource net_log; | 1042 NetLogWithSource net_log; |
1045 SpdyHttpStream http_stream(session_, true); | 1043 SpdyHttpStream http_stream(session_, true, net_log.source()); |
1046 ASSERT_THAT(http_stream.InitializeStream(&request, DEFAULT_PRIORITY, net_log, | 1044 ASSERT_THAT(http_stream.InitializeStream(&request, DEFAULT_PRIORITY, net_log, |
1047 CompletionCallback()), | 1045 CompletionCallback()), |
1048 IsOk()); | 1046 IsOk()); |
1049 | 1047 |
1050 CancelStreamCallback callback(&http_stream); | 1048 CancelStreamCallback callback(&http_stream); |
1051 HttpRequestHeaders headers; | 1049 HttpRequestHeaders headers; |
1052 HttpResponseInfo response; | 1050 HttpResponseInfo response; |
1053 // This will attempt to Write() the initial request and headers, which will | 1051 // This will attempt to Write() the initial request and headers, which will |
1054 // complete asynchronously. | 1052 // complete asynchronously. |
1055 EXPECT_THAT(http_stream.SendRequest(headers, &response, callback.callback()), | 1053 EXPECT_THAT(http_stream.SendRequest(headers, &response, callback.callback()), |
1056 IsError(ERR_IO_PENDING)); | 1054 IsError(ERR_IO_PENDING)); |
1057 EXPECT_TRUE(HasSpdySession(http_session_->spdy_session_pool(), key_)); | 1055 EXPECT_TRUE(HasSpdySession(http_session_->spdy_session_pool(), key_)); |
1058 | 1056 |
1059 // The callback cancels |http_stream|. | 1057 // The callback cancels |http_stream|. |
1060 EXPECT_THAT(callback.WaitForResult(), IsOk()); | 1058 EXPECT_THAT(callback.WaitForResult(), IsOk()); |
1061 | 1059 |
1062 // Finish async network reads/writes. | 1060 // Finish async network reads/writes. |
1063 base::RunLoop().RunUntilIdle(); | 1061 base::RunLoop().RunUntilIdle(); |
1064 | 1062 |
1065 EXPECT_FALSE(HasSpdySession(http_session_->spdy_session_pool(), key_)); | 1063 EXPECT_FALSE(HasSpdySession(http_session_->spdy_session_pool(), key_)); |
1066 } | 1064 } |
1067 | 1065 |
1068 // TODO(willchan): Write a longer test for SpdyStream that exercises all | 1066 // TODO(willchan): Write a longer test for SpdyStream that exercises all |
1069 // methods. | 1067 // methods. |
1070 | 1068 |
1071 } // namespace test | 1069 } // namespace test |
1072 | 1070 |
1073 } // namespace net | 1071 } // namespace net |
OLD | NEW |