Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(95)

Side by Side Diff: net/http/http_network_transaction_unittest.cc

Issue 384024: There was confusion in the mock socket classes due to... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/http/http_network_layer_unittest.cc ('k') | net/socket/socket_test_util.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 <math.h> // ceil 5 #include <math.h> // ceil
6 6
7 #include "base/compiler_specific.h" 7 #include "base/compiler_specific.h"
8 #include "net/base/completion_callback.h" 8 #include "net/base/completion_callback.h"
9 #include "net/base/mock_host_resolver.h" 9 #include "net/base/mock_host_resolver.h"
10 #include "net/base/ssl_config_service_defaults.h" 10 #include "net/base/ssl_config_service_defaults.h"
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 96
97 SessionDependencies session_deps; 97 SessionDependencies session_deps;
98 scoped_ptr<HttpTransaction> trans( 98 scoped_ptr<HttpTransaction> trans(
99 new HttpNetworkTransaction(CreateSession(&session_deps))); 99 new HttpNetworkTransaction(CreateSession(&session_deps)));
100 100
101 HttpRequestInfo request; 101 HttpRequestInfo request;
102 request.method = "GET"; 102 request.method = "GET";
103 request.url = GURL("http://www.google.com/"); 103 request.url = GURL("http://www.google.com/");
104 request.load_flags = 0; 104 request.load_flags = 0;
105 105
106 StaticMockSocket data(data_reads, NULL); 106 StaticSocketDataProvider data(data_reads, NULL);
107 session_deps.socket_factory.AddMockSocket(&data); 107 session_deps.socket_factory.AddSocketDataProvider(&data);
108 108
109 TestCompletionCallback callback; 109 TestCompletionCallback callback;
110 110
111 int rv = trans->Start(&request, &callback, NULL); 111 int rv = trans->Start(&request, &callback, NULL);
112 EXPECT_EQ(ERR_IO_PENDING, rv); 112 EXPECT_EQ(ERR_IO_PENDING, rv);
113 113
114 out.rv = callback.WaitForResult(); 114 out.rv = callback.WaitForResult();
115 if (out.rv != OK) 115 if (out.rv != OK)
116 return out; 116 return out;
117 117
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 }; 365 };
366 MockRead data_reads1[] = { 366 MockRead data_reads1[] = {
367 MockRead("HTTP/1.1 404 Not Found\r\n"), 367 MockRead("HTTP/1.1 404 Not Found\r\n"),
368 MockRead("Server: Blah\r\n"), 368 MockRead("Server: Blah\r\n"),
369 MockRead("Content-Length: 1234\r\n\r\n"), 369 MockRead("Content-Length: 1234\r\n\r\n"),
370 370
371 // No response body because the test stops reading here. 371 // No response body because the test stops reading here.
372 MockRead(false, ERR_UNEXPECTED), // Should not be reached. 372 MockRead(false, ERR_UNEXPECTED), // Should not be reached.
373 }; 373 };
374 374
375 StaticMockSocket data1(data_reads1, data_writes1); 375 StaticSocketDataProvider data1(data_reads1, data_writes1);
376 session_deps.socket_factory.AddMockSocket(&data1); 376 session_deps.socket_factory.AddSocketDataProvider(&data1);
377 377
378 TestCompletionCallback callback1; 378 TestCompletionCallback callback1;
379 379
380 int rv = trans->Start(&request, &callback1, NULL); 380 int rv = trans->Start(&request, &callback1, NULL);
381 EXPECT_EQ(ERR_IO_PENDING, rv); 381 EXPECT_EQ(ERR_IO_PENDING, rv);
382 382
383 rv = callback1.WaitForResult(); 383 rv = callback1.WaitForResult();
384 EXPECT_EQ(OK, rv); 384 EXPECT_EQ(OK, rv);
385 385
386 const HttpResponseInfo* response = trans->GetResponseInfo(); 386 const HttpResponseInfo* response = trans->GetResponseInfo();
(...skipping 23 matching lines...) Expand all
410 SessionDependencies session_deps; 410 SessionDependencies session_deps;
411 scoped_refptr<HttpNetworkSession> session = CreateSession(&session_deps); 411 scoped_refptr<HttpNetworkSession> session = CreateSession(&session_deps);
412 412
413 MockRead data_reads[] = { 413 MockRead data_reads[] = {
414 MockRead("HTTP/1.1 200 OK\r\nContent-Length: 5\r\n\r\n"), 414 MockRead("HTTP/1.1 200 OK\r\nContent-Length: 5\r\n\r\n"),
415 MockRead("hello"), 415 MockRead("hello"),
416 MockRead("HTTP/1.1 200 OK\r\nContent-Length: 5\r\n\r\n"), 416 MockRead("HTTP/1.1 200 OK\r\nContent-Length: 5\r\n\r\n"),
417 MockRead("world"), 417 MockRead("world"),
418 MockRead(false, OK), 418 MockRead(false, OK),
419 }; 419 };
420 StaticMockSocket data(data_reads, NULL); 420 StaticSocketDataProvider data(data_reads, NULL);
421 session_deps.socket_factory.AddMockSocket(&data); 421 session_deps.socket_factory.AddSocketDataProvider(&data);
422 422
423 const char* kExpectedResponseData[] = { 423 const char* kExpectedResponseData[] = {
424 "hello", "world" 424 "hello", "world"
425 }; 425 };
426 426
427 for (int i = 0; i < 2; ++i) { 427 for (int i = 0; i < 2; ++i) {
428 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); 428 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session));
429 429
430 HttpRequestInfo request; 430 HttpRequestInfo request;
431 request.method = "GET"; 431 request.method = "GET";
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
464 request.upload_data = new UploadData; 464 request.upload_data = new UploadData;
465 request.upload_data->AppendBytes("foo", 3); 465 request.upload_data->AppendBytes("foo", 3);
466 request.load_flags = 0; 466 request.load_flags = 0;
467 467
468 MockRead data_reads[] = { 468 MockRead data_reads[] = {
469 MockRead("HTTP/1.0 100 Continue\r\n\r\n"), 469 MockRead("HTTP/1.0 100 Continue\r\n\r\n"),
470 MockRead("HTTP/1.0 200 OK\r\n\r\n"), 470 MockRead("HTTP/1.0 200 OK\r\n\r\n"),
471 MockRead("hello world"), 471 MockRead("hello world"),
472 MockRead(false, OK), 472 MockRead(false, OK),
473 }; 473 };
474 StaticMockSocket data(data_reads, NULL); 474 StaticSocketDataProvider data(data_reads, NULL);
475 session_deps.socket_factory.AddMockSocket(&data); 475 session_deps.socket_factory.AddSocketDataProvider(&data);
476 476
477 TestCompletionCallback callback; 477 TestCompletionCallback callback;
478 478
479 int rv = trans->Start(&request, &callback, NULL); 479 int rv = trans->Start(&request, &callback, NULL);
480 EXPECT_EQ(ERR_IO_PENDING, rv); 480 EXPECT_EQ(ERR_IO_PENDING, rv);
481 481
482 rv = callback.WaitForResult(); 482 rv = callback.WaitForResult();
483 EXPECT_EQ(OK, rv); 483 EXPECT_EQ(OK, rv);
484 484
485 const HttpResponseInfo* response = trans->GetResponseInfo(); 485 const HttpResponseInfo* response = trans->GetResponseInfo();
(...skipping 20 matching lines...) Expand all
506 request.method = "GET"; 506 request.method = "GET";
507 request.url = GURL("http://www.foo.com/"); 507 request.url = GURL("http://www.foo.com/");
508 request.load_flags = 0; 508 request.load_flags = 0;
509 509
510 MockRead data_reads[] = { 510 MockRead data_reads[] = {
511 MockRead("HTTP/1.1 102 Unspecified status code\r\n\r\n" 511 MockRead("HTTP/1.1 102 Unspecified status code\r\n\r\n"
512 "HTTP/1.1 200 OK\r\n\r\n"), 512 "HTTP/1.1 200 OK\r\n\r\n"),
513 MockRead("hello world"), 513 MockRead("hello world"),
514 MockRead(false, OK), 514 MockRead(false, OK),
515 }; 515 };
516 StaticMockSocket data(data_reads, NULL); 516 StaticSocketDataProvider data(data_reads, NULL);
517 session_deps.socket_factory.AddMockSocket(&data); 517 session_deps.socket_factory.AddSocketDataProvider(&data);
518 518
519 TestCompletionCallback callback; 519 TestCompletionCallback callback;
520 520
521 int rv = trans->Start(&request, &callback, NULL); 521 int rv = trans->Start(&request, &callback, NULL);
522 EXPECT_EQ(ERR_IO_PENDING, rv); 522 EXPECT_EQ(ERR_IO_PENDING, rv);
523 523
524 rv = callback.WaitForResult(); 524 rv = callback.WaitForResult();
525 EXPECT_EQ(OK, rv); 525 EXPECT_EQ(OK, rv);
526 526
527 const HttpResponseInfo* response = trans->GetResponseInfo(); 527 const HttpResponseInfo* response = trans->GetResponseInfo();
(...skipping 18 matching lines...) Expand all
546 HttpRequestInfo request; 546 HttpRequestInfo request;
547 request.method = "GET"; 547 request.method = "GET";
548 request.url = GURL("http://www.foo.com/"); 548 request.url = GURL("http://www.foo.com/");
549 request.load_flags = 0; 549 request.load_flags = 0;
550 550
551 MockRead data1_reads[] = { 551 MockRead data1_reads[] = {
552 MockRead("HTTP/1.1 200 OK\r\nContent-Length: 5\r\n\r\n"), 552 MockRead("HTTP/1.1 200 OK\r\nContent-Length: 5\r\n\r\n"),
553 MockRead("hello"), 553 MockRead("hello"),
554 read_failure, // Now, we reuse the connection and fail the first read. 554 read_failure, // Now, we reuse the connection and fail the first read.
555 }; 555 };
556 StaticMockSocket data1(data1_reads, NULL); 556 StaticSocketDataProvider data1(data1_reads, NULL);
557 session_deps.socket_factory.AddMockSocket(&data1); 557 session_deps.socket_factory.AddSocketDataProvider(&data1);
558 558
559 MockRead data2_reads[] = { 559 MockRead data2_reads[] = {
560 MockRead("HTTP/1.1 200 OK\r\nContent-Length: 5\r\n\r\n"), 560 MockRead("HTTP/1.1 200 OK\r\nContent-Length: 5\r\n\r\n"),
561 MockRead("world"), 561 MockRead("world"),
562 MockRead(true, OK), 562 MockRead(true, OK),
563 }; 563 };
564 StaticMockSocket data2(data2_reads, NULL); 564 StaticSocketDataProvider data2(data2_reads, NULL);
565 session_deps.socket_factory.AddMockSocket(&data2); 565 session_deps.socket_factory.AddSocketDataProvider(&data2);
566 566
567 const char* kExpectedResponseData[] = { 567 const char* kExpectedResponseData[] = {
568 "hello", "world" 568 "hello", "world"
569 }; 569 };
570 570
571 for (int i = 0; i < 2; ++i) { 571 for (int i = 0; i < 2; ++i) {
572 TestCompletionCallback callback; 572 TestCompletionCallback callback;
573 573
574 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session)); 574 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(session));
575 575
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
611 request.method = "GET"; 611 request.method = "GET";
612 request.url = GURL("http://www.google.com/"); 612 request.url = GURL("http://www.google.com/");
613 request.load_flags = 0; 613 request.load_flags = 0;
614 614
615 MockRead data_reads[] = { 615 MockRead data_reads[] = {
616 MockRead(true, ERR_CONNECTION_RESET), 616 MockRead(true, ERR_CONNECTION_RESET),
617 MockRead("HTTP/1.0 200 OK\r\n\r\n"), // Should not be used 617 MockRead("HTTP/1.0 200 OK\r\n\r\n"), // Should not be used
618 MockRead("hello world"), 618 MockRead("hello world"),
619 MockRead(false, OK), 619 MockRead(false, OK),
620 }; 620 };
621 StaticMockSocket data(data_reads, NULL); 621 StaticSocketDataProvider data(data_reads, NULL);
622 session_deps.socket_factory.AddMockSocket(&data); 622 session_deps.socket_factory.AddSocketDataProvider(&data);
623 623
624 TestCompletionCallback callback; 624 TestCompletionCallback callback;
625 625
626 int rv = trans->Start(&request, &callback, NULL); 626 int rv = trans->Start(&request, &callback, NULL);
627 EXPECT_EQ(ERR_IO_PENDING, rv); 627 EXPECT_EQ(ERR_IO_PENDING, rv);
628 628
629 rv = callback.WaitForResult(); 629 rv = callback.WaitForResult();
630 EXPECT_EQ(ERR_CONNECTION_RESET, rv); 630 EXPECT_EQ(ERR_CONNECTION_RESET, rv);
631 631
632 const HttpResponseInfo* response = trans->GetResponseInfo(); 632 const HttpResponseInfo* response = trans->GetResponseInfo();
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
694 }; 694 };
695 695
696 // Lastly, the server responds with the actual content. 696 // Lastly, the server responds with the actual content.
697 MockRead data_reads2[] = { 697 MockRead data_reads2[] = {
698 MockRead("HTTP/1.0 200 OK\r\n"), 698 MockRead("HTTP/1.0 200 OK\r\n"),
699 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n"), 699 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n"),
700 MockRead("Content-Length: 100\r\n\r\n"), 700 MockRead("Content-Length: 100\r\n\r\n"),
701 MockRead(false, OK), 701 MockRead(false, OK),
702 }; 702 };
703 703
704 StaticMockSocket data1(data_reads1, data_writes1); 704 StaticSocketDataProvider data1(data_reads1, data_writes1);
705 StaticMockSocket data2(data_reads2, data_writes2); 705 StaticSocketDataProvider data2(data_reads2, data_writes2);
706 session_deps.socket_factory.AddMockSocket(&data1); 706 session_deps.socket_factory.AddSocketDataProvider(&data1);
707 session_deps.socket_factory.AddMockSocket(&data2); 707 session_deps.socket_factory.AddSocketDataProvider(&data2);
708 708
709 TestCompletionCallback callback1; 709 TestCompletionCallback callback1;
710 710
711 int rv = trans->Start(&request, &callback1, NULL); 711 int rv = trans->Start(&request, &callback1, NULL);
712 EXPECT_EQ(ERR_IO_PENDING, rv); 712 EXPECT_EQ(ERR_IO_PENDING, rv);
713 713
714 rv = callback1.WaitForResult(); 714 rv = callback1.WaitForResult();
715 EXPECT_EQ(OK, rv); 715 EXPECT_EQ(OK, rv);
716 716
717 const HttpResponseInfo* response = trans->GetResponseInfo(); 717 const HttpResponseInfo* response = trans->GetResponseInfo();
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
756 756
757 MockRead data_reads[] = { 757 MockRead data_reads[] = {
758 MockRead("HTTP/1.0 401 Unauthorized\r\n"), 758 MockRead("HTTP/1.0 401 Unauthorized\r\n"),
759 MockRead("WWW-Authenticate: Basic realm=\"MyRealm1\"\r\n"), 759 MockRead("WWW-Authenticate: Basic realm=\"MyRealm1\"\r\n"),
760 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n"), 760 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n"),
761 // Large content-length -- won't matter, as connection will be reset. 761 // Large content-length -- won't matter, as connection will be reset.
762 MockRead("Content-Length: 10000\r\n\r\n"), 762 MockRead("Content-Length: 10000\r\n\r\n"),
763 MockRead(false, ERR_FAILED), 763 MockRead(false, ERR_FAILED),
764 }; 764 };
765 765
766 StaticMockSocket data(data_reads, data_writes); 766 StaticSocketDataProvider data(data_reads, data_writes);
767 session_deps.socket_factory.AddMockSocket(&data); 767 session_deps.socket_factory.AddSocketDataProvider(&data);
768 TestCompletionCallback callback; 768 TestCompletionCallback callback;
769 769
770 int rv = trans->Start(&request, &callback, NULL); 770 int rv = trans->Start(&request, &callback, NULL);
771 EXPECT_EQ(ERR_IO_PENDING, rv); 771 EXPECT_EQ(ERR_IO_PENDING, rv);
772 772
773 rv = callback.WaitForResult(); 773 rv = callback.WaitForResult();
774 EXPECT_EQ(0, rv); 774 EXPECT_EQ(0, rv);
775 775
776 const HttpResponseInfo* response = trans->GetResponseInfo(); 776 const HttpResponseInfo* response = trans->GetResponseInfo();
777 ASSERT_FALSE(response == NULL); 777 ASSERT_FALSE(response == NULL);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
810 MockRead("Content-Length: 14\r\n\r\n"), 810 MockRead("Content-Length: 14\r\n\r\n"),
811 MockRead("Unauthorized\r\n"), 811 MockRead("Unauthorized\r\n"),
812 812
813 // Lastly, the server responds with the actual content. 813 // Lastly, the server responds with the actual content.
814 MockRead("HTTP/1.1 200 OK\r\n"), 814 MockRead("HTTP/1.1 200 OK\r\n"),
815 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n"), 815 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n"),
816 MockRead("Content-Length: 100\r\n\r\n"), 816 MockRead("Content-Length: 100\r\n\r\n"),
817 MockRead(false, OK), 817 MockRead(false, OK),
818 }; 818 };
819 819
820 StaticMockSocket data1(data_reads1, data_writes1); 820 StaticSocketDataProvider data1(data_reads1, data_writes1);
821 session_deps.socket_factory.AddMockSocket(&data1); 821 session_deps.socket_factory.AddSocketDataProvider(&data1);
822 822
823 TestCompletionCallback callback1; 823 TestCompletionCallback callback1;
824 824
825 int rv = trans->Start(&request, &callback1, NULL); 825 int rv = trans->Start(&request, &callback1, NULL);
826 EXPECT_EQ(ERR_IO_PENDING, rv); 826 EXPECT_EQ(ERR_IO_PENDING, rv);
827 827
828 rv = callback1.WaitForResult(); 828 rv = callback1.WaitForResult();
829 EXPECT_EQ(OK, rv); 829 EXPECT_EQ(OK, rv);
830 830
831 const HttpResponseInfo* response = trans->GetResponseInfo(); 831 const HttpResponseInfo* response = trans->GetResponseInfo();
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
887 MockRead("WWW-Authenticate: Basic realm=\"MyRealm1\"\r\n"), 887 MockRead("WWW-Authenticate: Basic realm=\"MyRealm1\"\r\n"),
888 MockRead("Content-Length: 0\r\n\r\n"), 888 MockRead("Content-Length: 0\r\n\r\n"),
889 889
890 // Lastly, the server responds with the actual content. 890 // Lastly, the server responds with the actual content.
891 MockRead("HTTP/1.1 200 OK\r\n"), 891 MockRead("HTTP/1.1 200 OK\r\n"),
892 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n"), 892 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n"),
893 MockRead("Content-Length: 100\r\n\r\n"), 893 MockRead("Content-Length: 100\r\n\r\n"),
894 MockRead(false, OK), 894 MockRead(false, OK),
895 }; 895 };
896 896
897 StaticMockSocket data1(data_reads1, data_writes1); 897 StaticSocketDataProvider data1(data_reads1, data_writes1);
898 session_deps.socket_factory.AddMockSocket(&data1); 898 session_deps.socket_factory.AddSocketDataProvider(&data1);
899 899
900 TestCompletionCallback callback1; 900 TestCompletionCallback callback1;
901 901
902 int rv = trans->Start(&request, &callback1, NULL); 902 int rv = trans->Start(&request, &callback1, NULL);
903 EXPECT_EQ(ERR_IO_PENDING, rv); 903 EXPECT_EQ(ERR_IO_PENDING, rv);
904 904
905 rv = callback1.WaitForResult(); 905 rv = callback1.WaitForResult();
906 EXPECT_EQ(OK, rv); 906 EXPECT_EQ(OK, rv);
907 907
908 const HttpResponseInfo* response = trans->GetResponseInfo(); 908 const HttpResponseInfo* response = trans->GetResponseInfo();
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
967 MockRead("Content-Length: 5134\r\n\r\n"), 967 MockRead("Content-Length: 5134\r\n\r\n"),
968 MockRead(true, large_body_string.data(), large_body_string.size()), 968 MockRead(true, large_body_string.data(), large_body_string.size()),
969 969
970 // Lastly, the server responds with the actual content. 970 // Lastly, the server responds with the actual content.
971 MockRead("HTTP/1.1 200 OK\r\n"), 971 MockRead("HTTP/1.1 200 OK\r\n"),
972 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n"), 972 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n"),
973 MockRead("Content-Length: 100\r\n\r\n"), 973 MockRead("Content-Length: 100\r\n\r\n"),
974 MockRead(false, OK), 974 MockRead(false, OK),
975 }; 975 };
976 976
977 StaticMockSocket data1(data_reads1, data_writes1); 977 StaticSocketDataProvider data1(data_reads1, data_writes1);
978 session_deps.socket_factory.AddMockSocket(&data1); 978 session_deps.socket_factory.AddSocketDataProvider(&data1);
979 979
980 TestCompletionCallback callback1; 980 TestCompletionCallback callback1;
981 981
982 int rv = trans->Start(&request, &callback1, NULL); 982 int rv = trans->Start(&request, &callback1, NULL);
983 EXPECT_EQ(ERR_IO_PENDING, rv); 983 EXPECT_EQ(ERR_IO_PENDING, rv);
984 984
985 rv = callback1.WaitForResult(); 985 rv = callback1.WaitForResult();
986 EXPECT_EQ(OK, rv); 986 EXPECT_EQ(OK, rv);
987 987
988 const HttpResponseInfo* response = trans->GetResponseInfo(); 988 const HttpResponseInfo* response = trans->GetResponseInfo();
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
1049 MockRead("0123456789"), 1049 MockRead("0123456789"),
1050 1050
1051 // Wrong credentials (wrong password). 1051 // Wrong credentials (wrong password).
1052 MockRead("HTTP/1.1 407 Proxy Authentication Required\r\n"), 1052 MockRead("HTTP/1.1 407 Proxy Authentication Required\r\n"),
1053 MockRead("Proxy-Authenticate: Basic realm=\"MyRealm1\"\r\n"), 1053 MockRead("Proxy-Authenticate: Basic realm=\"MyRealm1\"\r\n"),
1054 MockRead("Content-Length: 10\r\n\r\n"), 1054 MockRead("Content-Length: 10\r\n\r\n"),
1055 // No response body because the test stops reading here. 1055 // No response body because the test stops reading here.
1056 MockRead(false, ERR_UNEXPECTED), // Should not be reached. 1056 MockRead(false, ERR_UNEXPECTED), // Should not be reached.
1057 }; 1057 };
1058 1058
1059 StaticMockSocket data1(data_reads1, data_writes1); 1059 StaticSocketDataProvider data1(data_reads1, data_writes1);
1060 session_deps.socket_factory.AddMockSocket(&data1); 1060 session_deps.socket_factory.AddSocketDataProvider(&data1);
1061 1061
1062 TestCompletionCallback callback1; 1062 TestCompletionCallback callback1;
1063 1063
1064 int rv = trans->Start(&request, &callback1, NULL); 1064 int rv = trans->Start(&request, &callback1, NULL);
1065 EXPECT_EQ(ERR_IO_PENDING, rv); 1065 EXPECT_EQ(ERR_IO_PENDING, rv);
1066 1066
1067 rv = callback1.WaitForResult(); 1067 rv = callback1.WaitForResult();
1068 EXPECT_EQ(OK, rv); 1068 EXPECT_EQ(OK, rv);
1069 1069
1070 const HttpResponseInfo* response = trans->GetResponseInfo(); 1070 const HttpResponseInfo* response = trans->GetResponseInfo();
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
1130 }; 1130 };
1131 1131
1132 // The proxy responds to the connect with a 407. 1132 // The proxy responds to the connect with a 407.
1133 MockRead data_reads[] = { 1133 MockRead data_reads[] = {
1134 MockRead("HTTP/1.1 407 Proxy Authentication Required\r\n"), 1134 MockRead("HTTP/1.1 407 Proxy Authentication Required\r\n"),
1135 MockRead("Proxy-Authenticate: Basic realm=\"MyRealm1\"\r\n"), 1135 MockRead("Proxy-Authenticate: Basic realm=\"MyRealm1\"\r\n"),
1136 MockRead("Content-Length: 10\r\n\r\n"), 1136 MockRead("Content-Length: 10\r\n\r\n"),
1137 MockRead(false, ERR_UNEXPECTED), // Should not be reached. 1137 MockRead(false, ERR_UNEXPECTED), // Should not be reached.
1138 }; 1138 };
1139 1139
1140 StaticMockSocket data(data_reads, data_writes); 1140 StaticSocketDataProvider data(data_reads, data_writes);
1141 session_deps.socket_factory.AddMockSocket(&data); 1141 session_deps.socket_factory.AddSocketDataProvider(&data);
1142 1142
1143 TestCompletionCallback callback; 1143 TestCompletionCallback callback;
1144 1144
1145 int rv = trans->Start(&request, &callback, NULL); 1145 int rv = trans->Start(&request, &callback, NULL);
1146 EXPECT_EQ(ERR_IO_PENDING, rv); 1146 EXPECT_EQ(ERR_IO_PENDING, rv);
1147 1147
1148 rv = callback.WaitForResult(); 1148 rv = callback.WaitForResult();
1149 EXPECT_EQ(OK, rv); 1149 EXPECT_EQ(OK, rv);
1150 1150
1151 const HttpResponseInfo* response = trans->GetResponseInfo(); 1151 const HttpResponseInfo* response = trans->GetResponseInfo();
(...skipping 30 matching lines...) Expand all
1182 "Proxy-Connection: keep-alive\r\n\r\n"), 1182 "Proxy-Connection: keep-alive\r\n\r\n"),
1183 }; 1183 };
1184 1184
1185 MockRead data_reads[] = { 1185 MockRead data_reads[] = {
1186 status, 1186 status,
1187 MockRead("Content-Length: 10\r\n\r\n"), 1187 MockRead("Content-Length: 10\r\n\r\n"),
1188 // No response body because the test stops reading here. 1188 // No response body because the test stops reading here.
1189 MockRead(false, ERR_UNEXPECTED), // Should not be reached. 1189 MockRead(false, ERR_UNEXPECTED), // Should not be reached.
1190 }; 1190 };
1191 1191
1192 StaticMockSocket data(data_reads, data_writes); 1192 StaticSocketDataProvider data(data_reads, data_writes);
1193 session_deps.socket_factory.AddMockSocket(&data); 1193 session_deps.socket_factory.AddSocketDataProvider(&data);
1194 1194
1195 TestCompletionCallback callback; 1195 TestCompletionCallback callback;
1196 1196
1197 int rv = trans->Start(&request, &callback, NULL); 1197 int rv = trans->Start(&request, &callback, NULL);
1198 EXPECT_EQ(ERR_IO_PENDING, rv); 1198 EXPECT_EQ(ERR_IO_PENDING, rv);
1199 1199
1200 rv = callback.WaitForResult(); 1200 rv = callback.WaitForResult();
1201 EXPECT_EQ(expected_status, rv); 1201 EXPECT_EQ(expected_status, rv);
1202 } 1202 }
1203 1203
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
1437 }; 1437 };
1438 1438
1439 // Lastly we get the desired content. 1439 // Lastly we get the desired content.
1440 MockRead data_reads3[] = { 1440 MockRead data_reads3[] = {
1441 MockRead("HTTP/1.0 200 OK\r\n"), 1441 MockRead("HTTP/1.0 200 OK\r\n"),
1442 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n"), 1442 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n"),
1443 MockRead("Content-Length: 100\r\n\r\n"), 1443 MockRead("Content-Length: 100\r\n\r\n"),
1444 MockRead(false, OK), 1444 MockRead(false, OK),
1445 }; 1445 };
1446 1446
1447 StaticMockSocket data1(data_reads1, data_writes1); 1447 StaticSocketDataProvider data1(data_reads1, data_writes1);
1448 StaticMockSocket data2(data_reads2, data_writes2); 1448 StaticSocketDataProvider data2(data_reads2, data_writes2);
1449 StaticMockSocket data3(data_reads3, data_writes3); 1449 StaticSocketDataProvider data3(data_reads3, data_writes3);
1450 session_deps.socket_factory.AddMockSocket(&data1); 1450 session_deps.socket_factory.AddSocketDataProvider(&data1);
1451 session_deps.socket_factory.AddMockSocket(&data2); 1451 session_deps.socket_factory.AddSocketDataProvider(&data2);
1452 session_deps.socket_factory.AddMockSocket(&data3); 1452 session_deps.socket_factory.AddSocketDataProvider(&data3);
1453 1453
1454 TestCompletionCallback callback1; 1454 TestCompletionCallback callback1;
1455 1455
1456 int rv = trans->Start(&request, &callback1, NULL); 1456 int rv = trans->Start(&request, &callback1, NULL);
1457 EXPECT_EQ(ERR_IO_PENDING, rv); 1457 EXPECT_EQ(ERR_IO_PENDING, rv);
1458 1458
1459 rv = callback1.WaitForResult(); 1459 rv = callback1.WaitForResult();
1460 EXPECT_EQ(OK, rv); 1460 EXPECT_EQ(OK, rv);
1461 1461
1462 const HttpResponseInfo* response = trans->GetResponseInfo(); 1462 const HttpResponseInfo* response = trans->GetResponseInfo();
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
1576 MockRead("You are not authorized to view this page\r\n"), 1576 MockRead("You are not authorized to view this page\r\n"),
1577 1577
1578 // Lastly we get the desired content. 1578 // Lastly we get the desired content.
1579 MockRead("HTTP/1.1 200 OK\r\n"), 1579 MockRead("HTTP/1.1 200 OK\r\n"),
1580 MockRead("Content-Type: text/html; charset=utf-8\r\n"), 1580 MockRead("Content-Type: text/html; charset=utf-8\r\n"),
1581 MockRead("Content-Length: 13\r\n\r\n"), 1581 MockRead("Content-Length: 13\r\n\r\n"),
1582 MockRead("Please Login\r\n"), 1582 MockRead("Please Login\r\n"),
1583 MockRead(false, OK), 1583 MockRead(false, OK),
1584 }; 1584 };
1585 1585
1586 StaticMockSocket data1(data_reads1, data_writes1); 1586 StaticSocketDataProvider data1(data_reads1, data_writes1);
1587 StaticMockSocket data2(data_reads2, data_writes2); 1587 StaticSocketDataProvider data2(data_reads2, data_writes2);
1588 session_deps.socket_factory.AddMockSocket(&data1); 1588 session_deps.socket_factory.AddSocketDataProvider(&data1);
1589 session_deps.socket_factory.AddMockSocket(&data2); 1589 session_deps.socket_factory.AddSocketDataProvider(&data2);
1590 1590
1591 TestCompletionCallback callback1; 1591 TestCompletionCallback callback1;
1592 1592
1593 int rv = trans->Start(&request, &callback1, NULL); 1593 int rv = trans->Start(&request, &callback1, NULL);
1594 EXPECT_EQ(ERR_IO_PENDING, rv); 1594 EXPECT_EQ(ERR_IO_PENDING, rv);
1595 1595
1596 rv = callback1.WaitForResult(); 1596 rv = callback1.WaitForResult();
1597 EXPECT_EQ(OK, rv); 1597 EXPECT_EQ(OK, rv);
1598 1598
1599 EXPECT_TRUE(trans->IsReadyToRestartForAuth()); 1599 EXPECT_TRUE(trans->IsReadyToRestartForAuth());
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
1746 MockRead("You are not authorized to view this page\r\n"), 1746 MockRead("You are not authorized to view this page\r\n"),
1747 1747
1748 // Lastly we get the desired content. 1748 // Lastly we get the desired content.
1749 MockRead("HTTP/1.1 200 OK\r\n"), 1749 MockRead("HTTP/1.1 200 OK\r\n"),
1750 MockRead("Content-Type: text/html; charset=utf-8\r\n"), 1750 MockRead("Content-Type: text/html; charset=utf-8\r\n"),
1751 MockRead("Content-Length: 13\r\n\r\n"), 1751 MockRead("Content-Length: 13\r\n\r\n"),
1752 MockRead("Please Login\r\n"), 1752 MockRead("Please Login\r\n"),
1753 MockRead(false, OK), 1753 MockRead(false, OK),
1754 }; 1754 };
1755 1755
1756 StaticMockSocket data1(data_reads1, data_writes1); 1756 StaticSocketDataProvider data1(data_reads1, data_writes1);
1757 StaticMockSocket data2(data_reads2, data_writes2); 1757 StaticSocketDataProvider data2(data_reads2, data_writes2);
1758 StaticMockSocket data3(data_reads3, data_writes3); 1758 StaticSocketDataProvider data3(data_reads3, data_writes3);
1759 session_deps.socket_factory.AddMockSocket(&data1); 1759 session_deps.socket_factory.AddSocketDataProvider(&data1);
1760 session_deps.socket_factory.AddMockSocket(&data2); 1760 session_deps.socket_factory.AddSocketDataProvider(&data2);
1761 session_deps.socket_factory.AddMockSocket(&data3); 1761 session_deps.socket_factory.AddSocketDataProvider(&data3);
1762 1762
1763 TestCompletionCallback callback1; 1763 TestCompletionCallback callback1;
1764 1764
1765 int rv = trans->Start(&request, &callback1, NULL); 1765 int rv = trans->Start(&request, &callback1, NULL);
1766 EXPECT_EQ(ERR_IO_PENDING, rv); 1766 EXPECT_EQ(ERR_IO_PENDING, rv);
1767 1767
1768 rv = callback1.WaitForResult(); 1768 rv = callback1.WaitForResult();
1769 EXPECT_EQ(OK, rv); 1769 EXPECT_EQ(OK, rv);
1770 1770
1771 EXPECT_TRUE(trans->IsReadyToRestartForAuth()); 1771 EXPECT_TRUE(trans->IsReadyToRestartForAuth());
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
1844 // Respond with 300 kb of headers (we should fail after 256 kb). 1844 // Respond with 300 kb of headers (we should fail after 256 kb).
1845 std::string large_headers_string; 1845 std::string large_headers_string;
1846 FillLargeHeadersString(&large_headers_string, 300 * 1024); 1846 FillLargeHeadersString(&large_headers_string, 300 * 1024);
1847 1847
1848 MockRead data_reads[] = { 1848 MockRead data_reads[] = {
1849 MockRead("HTTP/1.0 200 OK\r\n"), 1849 MockRead("HTTP/1.0 200 OK\r\n"),
1850 MockRead(true, large_headers_string.data(), large_headers_string.size()), 1850 MockRead(true, large_headers_string.data(), large_headers_string.size()),
1851 MockRead("\r\nBODY"), 1851 MockRead("\r\nBODY"),
1852 MockRead(false, OK), 1852 MockRead(false, OK),
1853 }; 1853 };
1854 StaticMockSocket data(data_reads, NULL); 1854 StaticSocketDataProvider data(data_reads, NULL);
1855 session_deps.socket_factory.AddMockSocket(&data); 1855 session_deps.socket_factory.AddSocketDataProvider(&data);
1856 1856
1857 TestCompletionCallback callback; 1857 TestCompletionCallback callback;
1858 1858
1859 int rv = trans->Start(&request, &callback, NULL); 1859 int rv = trans->Start(&request, &callback, NULL);
1860 EXPECT_EQ(ERR_IO_PENDING, rv); 1860 EXPECT_EQ(ERR_IO_PENDING, rv);
1861 1861
1862 rv = callback.WaitForResult(); 1862 rv = callback.WaitForResult();
1863 EXPECT_EQ(ERR_RESPONSE_HEADERS_TOO_BIG, rv); 1863 EXPECT_EQ(ERR_RESPONSE_HEADERS_TOO_BIG, rv);
1864 1864
1865 const HttpResponseInfo* response = trans->GetResponseInfo(); 1865 const HttpResponseInfo* response = trans->GetResponseInfo();
(...skipping 25 matching lines...) Expand all
1891 1891
1892 // The proxy responds to the connect with a 404, using a persistent 1892 // The proxy responds to the connect with a 404, using a persistent
1893 // connection. Usually a proxy would return 501 (not implemented), 1893 // connection. Usually a proxy would return 501 (not implemented),
1894 // or 200 (tunnel established). 1894 // or 200 (tunnel established).
1895 MockRead data_reads1[] = { 1895 MockRead data_reads1[] = {
1896 MockRead("HTTP/1.1 404 Not Found\r\n"), 1896 MockRead("HTTP/1.1 404 Not Found\r\n"),
1897 MockRead("Content-Length: 10\r\n\r\n"), 1897 MockRead("Content-Length: 10\r\n\r\n"),
1898 MockRead(false, ERR_UNEXPECTED), // Should not be reached. 1898 MockRead(false, ERR_UNEXPECTED), // Should not be reached.
1899 }; 1899 };
1900 1900
1901 StaticMockSocket data1(data_reads1, data_writes1); 1901 StaticSocketDataProvider data1(data_reads1, data_writes1);
1902 session_deps.socket_factory.AddMockSocket(&data1); 1902 session_deps.socket_factory.AddSocketDataProvider(&data1);
1903 1903
1904 TestCompletionCallback callback1; 1904 TestCompletionCallback callback1;
1905 1905
1906 int rv = trans->Start(&request, &callback1, NULL); 1906 int rv = trans->Start(&request, &callback1, NULL);
1907 EXPECT_EQ(ERR_IO_PENDING, rv); 1907 EXPECT_EQ(ERR_IO_PENDING, rv);
1908 1908
1909 rv = callback1.WaitForResult(); 1909 rv = callback1.WaitForResult();
1910 EXPECT_EQ(ERR_TUNNEL_CONNECTION_FAILED, rv); 1910 EXPECT_EQ(ERR_TUNNEL_CONNECTION_FAILED, rv);
1911 1911
1912 const HttpResponseInfo* response = trans->GetResponseInfo(); 1912 const HttpResponseInfo* response = trans->GetResponseInfo();
(...skipping 27 matching lines...) Expand all
1940 MockRead data_reads[] = { 1940 MockRead data_reads[] = {
1941 // A part of the response body is received with the response headers. 1941 // A part of the response body is received with the response headers.
1942 MockRead("HTTP/1.1 200 OK\r\nContent-Length: 11\r\n\r\nhel"), 1942 MockRead("HTTP/1.1 200 OK\r\nContent-Length: 11\r\n\r\nhel"),
1943 // The rest of the response body is received in two parts. 1943 // The rest of the response body is received in two parts.
1944 MockRead("lo"), 1944 MockRead("lo"),
1945 MockRead(" world"), 1945 MockRead(" world"),
1946 MockRead("junk"), // Should not be read!! 1946 MockRead("junk"), // Should not be read!!
1947 MockRead(false, OK), 1947 MockRead(false, OK),
1948 }; 1948 };
1949 1949
1950 StaticMockSocket data(data_reads, NULL); 1950 StaticSocketDataProvider data(data_reads, NULL);
1951 session_deps.socket_factory.AddMockSocket(&data); 1951 session_deps.socket_factory.AddSocketDataProvider(&data);
1952 1952
1953 TestCompletionCallback callback; 1953 TestCompletionCallback callback;
1954 1954
1955 int rv = trans->Start(&request, &callback, NULL); 1955 int rv = trans->Start(&request, &callback, NULL);
1956 EXPECT_EQ(ERR_IO_PENDING, rv); 1956 EXPECT_EQ(ERR_IO_PENDING, rv);
1957 1957
1958 rv = callback.WaitForResult(); 1958 rv = callback.WaitForResult();
1959 EXPECT_EQ(OK, rv); 1959 EXPECT_EQ(OK, rv);
1960 1960
1961 const HttpResponseInfo* response = trans->GetResponseInfo(); 1961 const HttpResponseInfo* response = trans->GetResponseInfo();
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
1997 request.load_flags = 0; 1997 request.load_flags = 0;
1998 1998
1999 MockRead data_reads[] = { 1999 MockRead data_reads[] = {
2000 MockRead("HTTP/1.1 204 No Content\r\n" 2000 MockRead("HTTP/1.1 204 No Content\r\n"
2001 "Content-Length: 0\r\n" 2001 "Content-Length: 0\r\n"
2002 "Content-Type: text/html\r\n\r\n"), 2002 "Content-Type: text/html\r\n\r\n"),
2003 MockRead("junk"), // Should not be read!! 2003 MockRead("junk"), // Should not be read!!
2004 MockRead(false, OK), 2004 MockRead(false, OK),
2005 }; 2005 };
2006 2006
2007 StaticMockSocket data(data_reads, NULL); 2007 StaticSocketDataProvider data(data_reads, NULL);
2008 session_deps.socket_factory.AddMockSocket(&data); 2008 session_deps.socket_factory.AddSocketDataProvider(&data);
2009 2009
2010 TestCompletionCallback callback; 2010 TestCompletionCallback callback;
2011 2011
2012 int rv = trans->Start(&request, &callback, NULL); 2012 int rv = trans->Start(&request, &callback, NULL);
2013 EXPECT_EQ(ERR_IO_PENDING, rv); 2013 EXPECT_EQ(ERR_IO_PENDING, rv);
2014 2014
2015 rv = callback.WaitForResult(); 2015 rv = callback.WaitForResult();
2016 EXPECT_EQ(OK, rv); 2016 EXPECT_EQ(OK, rv);
2017 2017
2018 const HttpResponseInfo* response = trans->GetResponseInfo(); 2018 const HttpResponseInfo* response = trans->GetResponseInfo();
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
2066 MockRead("hello world"), 2066 MockRead("hello world"),
2067 MockRead(false, OK), 2067 MockRead(false, OK),
2068 }; 2068 };
2069 // The mock write results of transaction 1 and the first attempt of 2069 // The mock write results of transaction 1 and the first attempt of
2070 // transaction 2. 2070 // transaction 2.
2071 MockWrite data_writes1[] = { 2071 MockWrite data_writes1[] = {
2072 MockWrite(false, 64), // GET 2072 MockWrite(false, 64), // GET
2073 MockWrite(false, 93), // POST 2073 MockWrite(false, 93), // POST
2074 MockWrite(false, ERR_CONNECTION_ABORTED), // POST data 2074 MockWrite(false, ERR_CONNECTION_ABORTED), // POST data
2075 }; 2075 };
2076 StaticMockSocket data1(data_reads1, data_writes1); 2076 StaticSocketDataProvider data1(data_reads1, data_writes1);
2077 2077
2078 // The second socket is used for the second attempt of transaction 2. 2078 // The second socket is used for the second attempt of transaction 2.
2079 2079
2080 // The response of transaction 2. 2080 // The response of transaction 2.
2081 MockRead data_reads2[] = { 2081 MockRead data_reads2[] = {
2082 MockRead("HTTP/1.1 200 OK\r\nContent-Length: 7\r\n\r\n"), 2082 MockRead("HTTP/1.1 200 OK\r\nContent-Length: 7\r\n\r\n"),
2083 MockRead("welcome"), 2083 MockRead("welcome"),
2084 MockRead(false, OK), 2084 MockRead(false, OK),
2085 }; 2085 };
2086 // The mock write results of the second attempt of transaction 2. 2086 // The mock write results of the second attempt of transaction 2.
2087 MockWrite data_writes2[] = { 2087 MockWrite data_writes2[] = {
2088 MockWrite(false, 93), // POST 2088 MockWrite(false, 93), // POST
2089 MockWrite(false, 3), // POST data 2089 MockWrite(false, 3), // POST data
2090 }; 2090 };
2091 StaticMockSocket data2(data_reads2, data_writes2); 2091 StaticSocketDataProvider data2(data_reads2, data_writes2);
2092 2092
2093 session_deps.socket_factory.AddMockSocket(&data1); 2093 session_deps.socket_factory.AddSocketDataProvider(&data1);
2094 session_deps.socket_factory.AddMockSocket(&data2); 2094 session_deps.socket_factory.AddSocketDataProvider(&data2);
2095 2095
2096 const char* kExpectedResponseData[] = { 2096 const char* kExpectedResponseData[] = {
2097 "hello world", "welcome" 2097 "hello world", "welcome"
2098 }; 2098 };
2099 2099
2100 for (int i = 0; i < 2; ++i) { 2100 for (int i = 0; i < 2; ++i) {
2101 scoped_ptr<HttpTransaction> trans( 2101 scoped_ptr<HttpTransaction> trans(
2102 new HttpNetworkTransaction(session)); 2102 new HttpNetworkTransaction(session));
2103 2103
2104 TestCompletionCallback callback; 2104 TestCompletionCallback callback;
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
2162 "Connection: keep-alive\r\n" 2162 "Connection: keep-alive\r\n"
2163 "Authorization: Basic Zm9vOmJAcg==\r\n\r\n"), 2163 "Authorization: Basic Zm9vOmJAcg==\r\n\r\n"),
2164 }; 2164 };
2165 2165
2166 MockRead data_reads2[] = { 2166 MockRead data_reads2[] = {
2167 MockRead("HTTP/1.0 200 OK\r\n"), 2167 MockRead("HTTP/1.0 200 OK\r\n"),
2168 MockRead("Content-Length: 100\r\n\r\n"), 2168 MockRead("Content-Length: 100\r\n\r\n"),
2169 MockRead(false, OK), 2169 MockRead(false, OK),
2170 }; 2170 };
2171 2171
2172 StaticMockSocket data1(data_reads1, data_writes1); 2172 StaticSocketDataProvider data1(data_reads1, data_writes1);
2173 StaticMockSocket data2(data_reads2, data_writes2); 2173 StaticSocketDataProvider data2(data_reads2, data_writes2);
2174 session_deps.socket_factory.AddMockSocket(&data1); 2174 session_deps.socket_factory.AddSocketDataProvider(&data1);
2175 session_deps.socket_factory.AddMockSocket(&data2); 2175 session_deps.socket_factory.AddSocketDataProvider(&data2);
2176 2176
2177 TestCompletionCallback callback1; 2177 TestCompletionCallback callback1;
2178 2178
2179 int rv = trans->Start(&request, &callback1, NULL); 2179 int rv = trans->Start(&request, &callback1, NULL);
2180 EXPECT_EQ(ERR_IO_PENDING, rv); 2180 EXPECT_EQ(ERR_IO_PENDING, rv);
2181 2181
2182 rv = callback1.WaitForResult(); 2182 rv = callback1.WaitForResult();
2183 EXPECT_EQ(OK, rv); 2183 EXPECT_EQ(OK, rv);
2184 2184
2185 EXPECT_TRUE(trans->IsReadyToRestartForAuth()); 2185 EXPECT_TRUE(trans->IsReadyToRestartForAuth());
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
2255 "Connection: keep-alive\r\n" 2255 "Connection: keep-alive\r\n"
2256 "Authorization: Basic Zm9vOmJhcg==\r\n\r\n"), 2256 "Authorization: Basic Zm9vOmJhcg==\r\n\r\n"),
2257 }; 2257 };
2258 2258
2259 MockRead data_reads3[] = { 2259 MockRead data_reads3[] = {
2260 MockRead("HTTP/1.0 200 OK\r\n"), 2260 MockRead("HTTP/1.0 200 OK\r\n"),
2261 MockRead("Content-Length: 100\r\n\r\n"), 2261 MockRead("Content-Length: 100\r\n\r\n"),
2262 MockRead(false, OK), 2262 MockRead(false, OK),
2263 }; 2263 };
2264 2264
2265 StaticMockSocket data1(data_reads1, data_writes1); 2265 StaticSocketDataProvider data1(data_reads1, data_writes1);
2266 StaticMockSocket data2(data_reads2, data_writes2); 2266 StaticSocketDataProvider data2(data_reads2, data_writes2);
2267 StaticMockSocket data3(data_reads3, data_writes3); 2267 StaticSocketDataProvider data3(data_reads3, data_writes3);
2268 session_deps.socket_factory.AddMockSocket(&data1); 2268 session_deps.socket_factory.AddSocketDataProvider(&data1);
2269 session_deps.socket_factory.AddMockSocket(&data2); 2269 session_deps.socket_factory.AddSocketDataProvider(&data2);
2270 session_deps.socket_factory.AddMockSocket(&data3); 2270 session_deps.socket_factory.AddSocketDataProvider(&data3);
2271 2271
2272 TestCompletionCallback callback1; 2272 TestCompletionCallback callback1;
2273 2273
2274 int rv = trans->Start(&request, &callback1, NULL); 2274 int rv = trans->Start(&request, &callback1, NULL);
2275 EXPECT_EQ(ERR_IO_PENDING, rv); 2275 EXPECT_EQ(ERR_IO_PENDING, rv);
2276 2276
2277 rv = callback1.WaitForResult(); 2277 rv = callback1.WaitForResult();
2278 EXPECT_EQ(OK, rv); 2278 EXPECT_EQ(OK, rv);
2279 2279
2280 EXPECT_TRUE(trans->IsReadyToRestartForAuth()); 2280 EXPECT_TRUE(trans->IsReadyToRestartForAuth());
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
2348 "Authorization: Basic Zm9vOmJhcg==\r\n\r\n"), 2348 "Authorization: Basic Zm9vOmJhcg==\r\n\r\n"),
2349 }; 2349 };
2350 2350
2351 // Sever accepts the authorization. 2351 // Sever accepts the authorization.
2352 MockRead data_reads2[] = { 2352 MockRead data_reads2[] = {
2353 MockRead("HTTP/1.0 200 OK\r\n"), 2353 MockRead("HTTP/1.0 200 OK\r\n"),
2354 MockRead("Content-Length: 100\r\n\r\n"), 2354 MockRead("Content-Length: 100\r\n\r\n"),
2355 MockRead(false, OK), 2355 MockRead(false, OK),
2356 }; 2356 };
2357 2357
2358 StaticMockSocket data1(data_reads1, data_writes1); 2358 StaticSocketDataProvider data1(data_reads1, data_writes1);
2359 StaticMockSocket data2(data_reads2, data_writes2); 2359 StaticSocketDataProvider data2(data_reads2, data_writes2);
2360 session_deps.socket_factory.AddMockSocket(&data1); 2360 session_deps.socket_factory.AddSocketDataProvider(&data1);
2361 session_deps.socket_factory.AddMockSocket(&data2); 2361 session_deps.socket_factory.AddSocketDataProvider(&data2);
2362 2362
2363 TestCompletionCallback callback1; 2363 TestCompletionCallback callback1;
2364 2364
2365 int rv = trans->Start(&request, &callback1, NULL); 2365 int rv = trans->Start(&request, &callback1, NULL);
2366 EXPECT_EQ(ERR_IO_PENDING, rv); 2366 EXPECT_EQ(ERR_IO_PENDING, rv);
2367 2367
2368 rv = callback1.WaitForResult(); 2368 rv = callback1.WaitForResult();
2369 EXPECT_EQ(OK, rv); 2369 EXPECT_EQ(OK, rv);
2370 2370
2371 const HttpResponseInfo* response = trans->GetResponseInfo(); 2371 const HttpResponseInfo* response = trans->GetResponseInfo();
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
2431 "Authorization: Basic Zm9vMjpiYXIy\r\n\r\n"), 2431 "Authorization: Basic Zm9vMjpiYXIy\r\n\r\n"),
2432 }; 2432 };
2433 2433
2434 // Sever accepts the authorization. 2434 // Sever accepts the authorization.
2435 MockRead data_reads2[] = { 2435 MockRead data_reads2[] = {
2436 MockRead("HTTP/1.0 200 OK\r\n"), 2436 MockRead("HTTP/1.0 200 OK\r\n"),
2437 MockRead("Content-Length: 100\r\n\r\n"), 2437 MockRead("Content-Length: 100\r\n\r\n"),
2438 MockRead(false, OK), 2438 MockRead(false, OK),
2439 }; 2439 };
2440 2440
2441 StaticMockSocket data1(data_reads1, data_writes1); 2441 StaticSocketDataProvider data1(data_reads1, data_writes1);
2442 StaticMockSocket data2(data_reads2, data_writes2); 2442 StaticSocketDataProvider data2(data_reads2, data_writes2);
2443 session_deps.socket_factory.AddMockSocket(&data1); 2443 session_deps.socket_factory.AddSocketDataProvider(&data1);
2444 session_deps.socket_factory.AddMockSocket(&data2); 2444 session_deps.socket_factory.AddSocketDataProvider(&data2);
2445 2445
2446 TestCompletionCallback callback1; 2446 TestCompletionCallback callback1;
2447 2447
2448 int rv = trans->Start(&request, &callback1, NULL); 2448 int rv = trans->Start(&request, &callback1, NULL);
2449 EXPECT_EQ(ERR_IO_PENDING, rv); 2449 EXPECT_EQ(ERR_IO_PENDING, rv);
2450 2450
2451 rv = callback1.WaitForResult(); 2451 rv = callback1.WaitForResult();
2452 EXPECT_EQ(OK, rv); 2452 EXPECT_EQ(OK, rv);
2453 2453
2454 const HttpResponseInfo* response = trans->GetResponseInfo(); 2454 const HttpResponseInfo* response = trans->GetResponseInfo();
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
2497 "Authorization: Basic Zm9vOmJhcg==\r\n\r\n"), 2497 "Authorization: Basic Zm9vOmJhcg==\r\n\r\n"),
2498 }; 2498 };
2499 2499
2500 // Sever accepts the preemptive authorization 2500 // Sever accepts the preemptive authorization
2501 MockRead data_reads1[] = { 2501 MockRead data_reads1[] = {
2502 MockRead("HTTP/1.0 200 OK\r\n"), 2502 MockRead("HTTP/1.0 200 OK\r\n"),
2503 MockRead("Content-Length: 100\r\n\r\n"), 2503 MockRead("Content-Length: 100\r\n\r\n"),
2504 MockRead(false, OK), 2504 MockRead(false, OK),
2505 }; 2505 };
2506 2506
2507 StaticMockSocket data1(data_reads1, data_writes1); 2507 StaticSocketDataProvider data1(data_reads1, data_writes1);
2508 session_deps.socket_factory.AddMockSocket(&data1); 2508 session_deps.socket_factory.AddSocketDataProvider(&data1);
2509 2509
2510 TestCompletionCallback callback1; 2510 TestCompletionCallback callback1;
2511 2511
2512 int rv = trans->Start(&request, &callback1, NULL); 2512 int rv = trans->Start(&request, &callback1, NULL);
2513 EXPECT_EQ(ERR_IO_PENDING, rv); 2513 EXPECT_EQ(ERR_IO_PENDING, rv);
2514 2514
2515 rv = callback1.WaitForResult(); 2515 rv = callback1.WaitForResult();
2516 EXPECT_EQ(OK, rv); 2516 EXPECT_EQ(OK, rv);
2517 2517
2518 const HttpResponseInfo* response = trans->GetResponseInfo(); 2518 const HttpResponseInfo* response = trans->GetResponseInfo();
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
2555 "Authorization: Basic Zm9vOmJhcg==\r\n\r\n"), 2555 "Authorization: Basic Zm9vOmJhcg==\r\n\r\n"),
2556 }; 2556 };
2557 2557
2558 // Sever accepts the authorization. 2558 // Sever accepts the authorization.
2559 MockRead data_reads2[] = { 2559 MockRead data_reads2[] = {
2560 MockRead("HTTP/1.0 200 OK\r\n"), 2560 MockRead("HTTP/1.0 200 OK\r\n"),
2561 MockRead("Content-Length: 100\r\n\r\n"), 2561 MockRead("Content-Length: 100\r\n\r\n"),
2562 MockRead(false, OK), 2562 MockRead(false, OK),
2563 }; 2563 };
2564 2564
2565 StaticMockSocket data1(data_reads1, data_writes1); 2565 StaticSocketDataProvider data1(data_reads1, data_writes1);
2566 StaticMockSocket data2(data_reads2, data_writes2); 2566 StaticSocketDataProvider data2(data_reads2, data_writes2);
2567 session_deps.socket_factory.AddMockSocket(&data1); 2567 session_deps.socket_factory.AddSocketDataProvider(&data1);
2568 session_deps.socket_factory.AddMockSocket(&data2); 2568 session_deps.socket_factory.AddSocketDataProvider(&data2);
2569 2569
2570 TestCompletionCallback callback1; 2570 TestCompletionCallback callback1;
2571 2571
2572 int rv = trans->Start(&request, &callback1, NULL); 2572 int rv = trans->Start(&request, &callback1, NULL);
2573 EXPECT_EQ(ERR_IO_PENDING, rv); 2573 EXPECT_EQ(ERR_IO_PENDING, rv);
2574 2574
2575 rv = callback1.WaitForResult(); 2575 rv = callback1.WaitForResult();
2576 EXPECT_EQ(OK, rv); 2576 EXPECT_EQ(OK, rv);
2577 2577
2578 EXPECT_TRUE(trans->IsReadyToRestartForAuth()); 2578 EXPECT_TRUE(trans->IsReadyToRestartForAuth());
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
2639 "Authorization: Basic Zm9vMzpiYXIz\r\n\r\n"), 2639 "Authorization: Basic Zm9vMzpiYXIz\r\n\r\n"),
2640 }; 2640 };
2641 2641
2642 // Sever accepts the authorization. 2642 // Sever accepts the authorization.
2643 MockRead data_reads3[] = { 2643 MockRead data_reads3[] = {
2644 MockRead("HTTP/1.0 200 OK\r\n"), 2644 MockRead("HTTP/1.0 200 OK\r\n"),
2645 MockRead("Content-Length: 100\r\n\r\n"), 2645 MockRead("Content-Length: 100\r\n\r\n"),
2646 MockRead(false, OK), 2646 MockRead(false, OK),
2647 }; 2647 };
2648 2648
2649 StaticMockSocket data1(data_reads1, data_writes1); 2649 StaticSocketDataProvider data1(data_reads1, data_writes1);
2650 StaticMockSocket data2(data_reads2, data_writes2); 2650 StaticSocketDataProvider data2(data_reads2, data_writes2);
2651 StaticMockSocket data3(data_reads3, data_writes3); 2651 StaticSocketDataProvider data3(data_reads3, data_writes3);
2652 session_deps.socket_factory.AddMockSocket(&data1); 2652 session_deps.socket_factory.AddSocketDataProvider(&data1);
2653 session_deps.socket_factory.AddMockSocket(&data2); 2653 session_deps.socket_factory.AddSocketDataProvider(&data2);
2654 session_deps.socket_factory.AddMockSocket(&data3); 2654 session_deps.socket_factory.AddSocketDataProvider(&data3);
2655 2655
2656 TestCompletionCallback callback1; 2656 TestCompletionCallback callback1;
2657 2657
2658 int rv = trans->Start(&request, &callback1, NULL); 2658 int rv = trans->Start(&request, &callback1, NULL);
2659 EXPECT_EQ(ERR_IO_PENDING, rv); 2659 EXPECT_EQ(ERR_IO_PENDING, rv);
2660 2660
2661 rv = callback1.WaitForResult(); 2661 rv = callback1.WaitForResult();
2662 EXPECT_EQ(OK, rv); 2662 EXPECT_EQ(OK, rv);
2663 2663
2664 EXPECT_TRUE(trans->IsReadyToRestartForAuth()); 2664 EXPECT_TRUE(trans->IsReadyToRestartForAuth());
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
2756 "Connection: keep-alive\r\n\r\n"), 2756 "Connection: keep-alive\r\n\r\n"),
2757 }; 2757 };
2758 2758
2759 MockRead data_reads[] = { 2759 MockRead data_reads[] = {
2760 MockRead("HTTP/1.0 200 OK\r\n"), 2760 MockRead("HTTP/1.0 200 OK\r\n"),
2761 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n"), 2761 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n"),
2762 MockRead("Content-Length: 100\r\n\r\n"), 2762 MockRead("Content-Length: 100\r\n\r\n"),
2763 MockRead(false, OK), 2763 MockRead(false, OK),
2764 }; 2764 };
2765 2765
2766 StaticMockSocket ssl_bad_certificate; 2766 StaticSocketDataProvider ssl_bad_certificate;
2767 StaticMockSocket data(data_reads, data_writes); 2767 StaticSocketDataProvider data(data_reads, data_writes);
2768 MockSSLSocket ssl_bad(true, ERR_CERT_AUTHORITY_INVALID); 2768 SSLSocketDataProvider ssl_bad(true, ERR_CERT_AUTHORITY_INVALID);
2769 MockSSLSocket ssl(true, OK); 2769 SSLSocketDataProvider ssl(true, OK);
2770 2770
2771 session_deps.socket_factory.AddMockSocket(&ssl_bad_certificate); 2771 session_deps.socket_factory.AddSocketDataProvider(&ssl_bad_certificate);
2772 session_deps.socket_factory.AddMockSocket(&data); 2772 session_deps.socket_factory.AddSocketDataProvider(&data);
2773 session_deps.socket_factory.AddMockSSLSocket(&ssl_bad); 2773 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl_bad);
2774 session_deps.socket_factory.AddMockSSLSocket(&ssl); 2774 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl);
2775 2775
2776 TestCompletionCallback callback; 2776 TestCompletionCallback callback;
2777 2777
2778 int rv = trans->Start(&request, &callback, NULL); 2778 int rv = trans->Start(&request, &callback, NULL);
2779 EXPECT_EQ(ERR_IO_PENDING, rv); 2779 EXPECT_EQ(ERR_IO_PENDING, rv);
2780 2780
2781 rv = callback.WaitForResult(); 2781 rv = callback.WaitForResult();
2782 EXPECT_EQ(ERR_CERT_AUTHORITY_INVALID, rv); 2782 EXPECT_EQ(ERR_CERT_AUTHORITY_INVALID, rv);
2783 2783
2784 rv = trans->RestartIgnoringLastError(&callback); 2784 rv = trans->RestartIgnoringLastError(&callback);
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
2824 }; 2824 };
2825 2825
2826 MockRead data_reads[] = { 2826 MockRead data_reads[] = {
2827 MockRead("HTTP/1.0 200 Connected\r\n\r\n"), 2827 MockRead("HTTP/1.0 200 Connected\r\n\r\n"),
2828 MockRead("HTTP/1.0 200 OK\r\n"), 2828 MockRead("HTTP/1.0 200 OK\r\n"),
2829 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n"), 2829 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n"),
2830 MockRead("Content-Length: 100\r\n\r\n"), 2830 MockRead("Content-Length: 100\r\n\r\n"),
2831 MockRead(false, OK), 2831 MockRead(false, OK),
2832 }; 2832 };
2833 2833
2834 StaticMockSocket ssl_bad_certificate(proxy_reads, proxy_writes); 2834 StaticSocketDataProvider ssl_bad_certificate(proxy_reads, proxy_writes);
2835 StaticMockSocket data(data_reads, data_writes); 2835 StaticSocketDataProvider data(data_reads, data_writes);
2836 MockSSLSocket ssl_bad(true, ERR_CERT_AUTHORITY_INVALID); 2836 SSLSocketDataProvider ssl_bad(true, ERR_CERT_AUTHORITY_INVALID);
2837 MockSSLSocket ssl(true, OK); 2837 SSLSocketDataProvider ssl(true, OK);
2838 2838
2839 session_deps.socket_factory.AddMockSocket(&ssl_bad_certificate); 2839 session_deps.socket_factory.AddSocketDataProvider(&ssl_bad_certificate);
2840 session_deps.socket_factory.AddMockSocket(&data); 2840 session_deps.socket_factory.AddSocketDataProvider(&data);
2841 session_deps.socket_factory.AddMockSSLSocket(&ssl_bad); 2841 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl_bad);
2842 session_deps.socket_factory.AddMockSSLSocket(&ssl); 2842 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl);
2843 2843
2844 TestCompletionCallback callback; 2844 TestCompletionCallback callback;
2845 2845
2846 for (int i = 0; i < 2; i++) { 2846 for (int i = 0; i < 2; i++) {
2847 session_deps.socket_factory.ResetNextMockIndexes(); 2847 session_deps.socket_factory.ResetNextMockIndexes();
2848 2848
2849 scoped_ptr<HttpTransaction> trans( 2849 scoped_ptr<HttpTransaction> trans(
2850 new HttpNetworkTransaction(CreateSession(&session_deps))); 2850 new HttpNetworkTransaction(CreateSession(&session_deps)));
2851 2851
2852 int rv = trans->Start(&request, &callback, NULL); 2852 int rv = trans->Start(&request, &callback, NULL);
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
2886 }; 2886 };
2887 2887
2888 // Lastly, the server responds with the actual content. 2888 // Lastly, the server responds with the actual content.
2889 MockRead data_reads[] = { 2889 MockRead data_reads[] = {
2890 MockRead("HTTP/1.0 200 OK\r\n"), 2890 MockRead("HTTP/1.0 200 OK\r\n"),
2891 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n"), 2891 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n"),
2892 MockRead("Content-Length: 100\r\n\r\n"), 2892 MockRead("Content-Length: 100\r\n\r\n"),
2893 MockRead(false, OK), 2893 MockRead(false, OK),
2894 }; 2894 };
2895 2895
2896 StaticMockSocket data(data_reads, data_writes); 2896 StaticSocketDataProvider data(data_reads, data_writes);
2897 session_deps.socket_factory.AddMockSocket(&data); 2897 session_deps.socket_factory.AddSocketDataProvider(&data);
2898 2898
2899 TestCompletionCallback callback; 2899 TestCompletionCallback callback;
2900 2900
2901 int rv = trans->Start(&request, &callback, NULL); 2901 int rv = trans->Start(&request, &callback, NULL);
2902 EXPECT_EQ(ERR_IO_PENDING, rv); 2902 EXPECT_EQ(ERR_IO_PENDING, rv);
2903 2903
2904 rv = callback.WaitForResult(); 2904 rv = callback.WaitForResult();
2905 EXPECT_EQ(OK, rv); 2905 EXPECT_EQ(OK, rv);
2906 } 2906 }
2907 2907
(...skipping 16 matching lines...) Expand all
2924 }; 2924 };
2925 2925
2926 // Lastly, the server responds with the actual content. 2926 // Lastly, the server responds with the actual content.
2927 MockRead data_reads[] = { 2927 MockRead data_reads[] = {
2928 MockRead("HTTP/1.0 200 OK\r\n"), 2928 MockRead("HTTP/1.0 200 OK\r\n"),
2929 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n"), 2929 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n"),
2930 MockRead("Content-Length: 100\r\n\r\n"), 2930 MockRead("Content-Length: 100\r\n\r\n"),
2931 MockRead(false, OK), 2931 MockRead(false, OK),
2932 }; 2932 };
2933 2933
2934 StaticMockSocket data(data_reads, data_writes); 2934 StaticSocketDataProvider data(data_reads, data_writes);
2935 session_deps.socket_factory.AddMockSocket(&data); 2935 session_deps.socket_factory.AddSocketDataProvider(&data);
2936 2936
2937 TestCompletionCallback callback; 2937 TestCompletionCallback callback;
2938 2938
2939 int rv = trans->Start(&request, &callback, NULL); 2939 int rv = trans->Start(&request, &callback, NULL);
2940 EXPECT_EQ(ERR_IO_PENDING, rv); 2940 EXPECT_EQ(ERR_IO_PENDING, rv);
2941 2941
2942 rv = callback.WaitForResult(); 2942 rv = callback.WaitForResult();
2943 EXPECT_EQ(OK, rv); 2943 EXPECT_EQ(OK, rv);
2944 } 2944 }
2945 2945
(...skipping 14 matching lines...) Expand all
2960 }; 2960 };
2961 2961
2962 // Lastly, the server responds with the actual content. 2962 // Lastly, the server responds with the actual content.
2963 MockRead data_reads[] = { 2963 MockRead data_reads[] = {
2964 MockRead("HTTP/1.0 200 OK\r\n"), 2964 MockRead("HTTP/1.0 200 OK\r\n"),
2965 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n"), 2965 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n"),
2966 MockRead("Content-Length: 100\r\n\r\n"), 2966 MockRead("Content-Length: 100\r\n\r\n"),
2967 MockRead(false, OK), 2967 MockRead(false, OK),
2968 }; 2968 };
2969 2969
2970 StaticMockSocket data(data_reads, data_writes); 2970 StaticSocketDataProvider data(data_reads, data_writes);
2971 session_deps.socket_factory.AddMockSocket(&data); 2971 session_deps.socket_factory.AddSocketDataProvider(&data);
2972 2972
2973 TestCompletionCallback callback; 2973 TestCompletionCallback callback;
2974 2974
2975 int rv = trans->Start(&request, &callback, NULL); 2975 int rv = trans->Start(&request, &callback, NULL);
2976 EXPECT_EQ(ERR_IO_PENDING, rv); 2976 EXPECT_EQ(ERR_IO_PENDING, rv);
2977 2977
2978 rv = callback.WaitForResult(); 2978 rv = callback.WaitForResult();
2979 EXPECT_EQ(OK, rv); 2979 EXPECT_EQ(OK, rv);
2980 } 2980 }
2981 2981
(...skipping 14 matching lines...) Expand all
2996 }; 2996 };
2997 2997
2998 // Lastly, the server responds with the actual content. 2998 // Lastly, the server responds with the actual content.
2999 MockRead data_reads[] = { 2999 MockRead data_reads[] = {
3000 MockRead("HTTP/1.0 200 OK\r\n"), 3000 MockRead("HTTP/1.0 200 OK\r\n"),
3001 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n"), 3001 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n"),
3002 MockRead("Content-Length: 100\r\n\r\n"), 3002 MockRead("Content-Length: 100\r\n\r\n"),
3003 MockRead(false, OK), 3003 MockRead(false, OK),
3004 }; 3004 };
3005 3005
3006 StaticMockSocket data(data_reads, data_writes); 3006 StaticSocketDataProvider data(data_reads, data_writes);
3007 session_deps.socket_factory.AddMockSocket(&data); 3007 session_deps.socket_factory.AddSocketDataProvider(&data);
3008 3008
3009 TestCompletionCallback callback; 3009 TestCompletionCallback callback;
3010 3010
3011 int rv = trans->Start(&request, &callback, NULL); 3011 int rv = trans->Start(&request, &callback, NULL);
3012 EXPECT_EQ(ERR_IO_PENDING, rv); 3012 EXPECT_EQ(ERR_IO_PENDING, rv);
3013 3013
3014 rv = callback.WaitForResult(); 3014 rv = callback.WaitForResult();
3015 EXPECT_EQ(OK, rv); 3015 EXPECT_EQ(OK, rv);
3016 } 3016 }
3017 3017
(...skipping 14 matching lines...) Expand all
3032 }; 3032 };
3033 3033
3034 // Lastly, the server responds with the actual content. 3034 // Lastly, the server responds with the actual content.
3035 MockRead data_reads[] = { 3035 MockRead data_reads[] = {
3036 MockRead("HTTP/1.0 200 OK\r\n"), 3036 MockRead("HTTP/1.0 200 OK\r\n"),
3037 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n"), 3037 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n"),
3038 MockRead("Content-Length: 100\r\n\r\n"), 3038 MockRead("Content-Length: 100\r\n\r\n"),
3039 MockRead(false, OK), 3039 MockRead(false, OK),
3040 }; 3040 };
3041 3041
3042 StaticMockSocket data(data_reads, data_writes); 3042 StaticSocketDataProvider data(data_reads, data_writes);
3043 session_deps.socket_factory.AddMockSocket(&data); 3043 session_deps.socket_factory.AddSocketDataProvider(&data);
3044 3044
3045 TestCompletionCallback callback; 3045 TestCompletionCallback callback;
3046 3046
3047 int rv = trans->Start(&request, &callback, NULL); 3047 int rv = trans->Start(&request, &callback, NULL);
3048 EXPECT_EQ(ERR_IO_PENDING, rv); 3048 EXPECT_EQ(ERR_IO_PENDING, rv);
3049 3049
3050 rv = callback.WaitForResult(); 3050 rv = callback.WaitForResult();
3051 EXPECT_EQ(OK, rv); 3051 EXPECT_EQ(OK, rv);
3052 } 3052 }
3053 3053
(...skipping 16 matching lines...) Expand all
3070 }; 3070 };
3071 3071
3072 // Lastly, the server responds with the actual content. 3072 // Lastly, the server responds with the actual content.
3073 MockRead data_reads[] = { 3073 MockRead data_reads[] = {
3074 MockRead("HTTP/1.0 200 OK\r\n"), 3074 MockRead("HTTP/1.0 200 OK\r\n"),
3075 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n"), 3075 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n"),
3076 MockRead("Content-Length: 100\r\n\r\n"), 3076 MockRead("Content-Length: 100\r\n\r\n"),
3077 MockRead(false, OK), 3077 MockRead(false, OK),
3078 }; 3078 };
3079 3079
3080 StaticMockSocket data(data_reads, data_writes); 3080 StaticSocketDataProvider data(data_reads, data_writes);
3081 session_deps.socket_factory.AddMockSocket(&data); 3081 session_deps.socket_factory.AddSocketDataProvider(&data);
3082 3082
3083 TestCompletionCallback callback; 3083 TestCompletionCallback callback;
3084 3084
3085 int rv = trans->Start(&request, &callback, NULL); 3085 int rv = trans->Start(&request, &callback, NULL);
3086 EXPECT_EQ(ERR_IO_PENDING, rv); 3086 EXPECT_EQ(ERR_IO_PENDING, rv);
3087 3087
3088 rv = callback.WaitForResult(); 3088 rv = callback.WaitForResult();
3089 EXPECT_EQ(OK, rv); 3089 EXPECT_EQ(OK, rv);
3090 } 3090 }
3091 3091
(...skipping 16 matching lines...) Expand all
3108 }; 3108 };
3109 3109
3110 // Lastly, the server responds with the actual content. 3110 // Lastly, the server responds with the actual content.
3111 MockRead data_reads[] = { 3111 MockRead data_reads[] = {
3112 MockRead("HTTP/1.0 200 OK\r\n"), 3112 MockRead("HTTP/1.0 200 OK\r\n"),
3113 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n"), 3113 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n"),
3114 MockRead("Content-Length: 100\r\n\r\n"), 3114 MockRead("Content-Length: 100\r\n\r\n"),
3115 MockRead(false, OK), 3115 MockRead(false, OK),
3116 }; 3116 };
3117 3117
3118 StaticMockSocket data(data_reads, data_writes); 3118 StaticSocketDataProvider data(data_reads, data_writes);
3119 session_deps.socket_factory.AddMockSocket(&data); 3119 session_deps.socket_factory.AddSocketDataProvider(&data);
3120 3120
3121 TestCompletionCallback callback; 3121 TestCompletionCallback callback;
3122 3122
3123 int rv = trans->Start(&request, &callback, NULL); 3123 int rv = trans->Start(&request, &callback, NULL);
3124 EXPECT_EQ(ERR_IO_PENDING, rv); 3124 EXPECT_EQ(ERR_IO_PENDING, rv);
3125 3125
3126 rv = callback.WaitForResult(); 3126 rv = callback.WaitForResult();
3127 EXPECT_EQ(OK, rv); 3127 EXPECT_EQ(OK, rv);
3128 } 3128 }
3129 3129
(...skipping 15 matching lines...) Expand all
3145 }; 3145 };
3146 3146
3147 // Lastly, the server responds with the actual content. 3147 // Lastly, the server responds with the actual content.
3148 MockRead data_reads[] = { 3148 MockRead data_reads[] = {
3149 MockRead("HTTP/1.0 200 OK\r\n"), 3149 MockRead("HTTP/1.0 200 OK\r\n"),
3150 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n"), 3150 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n"),
3151 MockRead("Content-Length: 100\r\n\r\n"), 3151 MockRead("Content-Length: 100\r\n\r\n"),
3152 MockRead(false, OK), 3152 MockRead(false, OK),
3153 }; 3153 };
3154 3154
3155 StaticMockSocket data(data_reads, data_writes); 3155 StaticSocketDataProvider data(data_reads, data_writes);
3156 session_deps.socket_factory.AddMockSocket(&data); 3156 session_deps.socket_factory.AddSocketDataProvider(&data);
3157 3157
3158 TestCompletionCallback callback; 3158 TestCompletionCallback callback;
3159 3159
3160 int rv = trans->Start(&request, &callback, NULL); 3160 int rv = trans->Start(&request, &callback, NULL);
3161 EXPECT_EQ(ERR_IO_PENDING, rv); 3161 EXPECT_EQ(ERR_IO_PENDING, rv);
3162 3162
3163 rv = callback.WaitForResult(); 3163 rv = callback.WaitForResult();
3164 EXPECT_EQ(OK, rv); 3164 EXPECT_EQ(OK, rv);
3165 } 3165 }
3166 3166
(...skipping 13 matching lines...) Expand all
3180 char read_buffer[] = { 0x00, 0x5A, 0x00, 0x00, 0, 0, 0, 0 }; 3180 char read_buffer[] = { 0x00, 0x5A, 0x00, 0x00, 0, 0, 0, 0 };
3181 3181
3182 MockWrite data_writes[] = { 3182 MockWrite data_writes[] = {
3183 MockWrite(true, write_buffer, arraysize(write_buffer)), 3183 MockWrite(true, write_buffer, arraysize(write_buffer)),
3184 MockWrite("GET / HTTP/1.1\r\n" 3184 MockWrite("GET / HTTP/1.1\r\n"
3185 "Host: www.google.com\r\n" 3185 "Host: www.google.com\r\n"
3186 "Connection: keep-alive\r\n\r\n") 3186 "Connection: keep-alive\r\n\r\n")
3187 }; 3187 };
3188 3188
3189 MockRead data_reads[] = { 3189 MockRead data_reads[] = {
3190 MockWrite(true, read_buffer, arraysize(read_buffer)), 3190 MockRead(true, read_buffer, arraysize(read_buffer)),
3191 MockRead("HTTP/1.0 200 OK\r\n"), 3191 MockRead("HTTP/1.0 200 OK\r\n"),
3192 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n\r\n"), 3192 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n\r\n"),
3193 MockRead("Payload"), 3193 MockRead("Payload"),
3194 MockRead(false, OK) 3194 MockRead(false, OK)
3195 }; 3195 };
3196 3196
3197 StaticMockSocket data(data_reads, data_writes); 3197 StaticSocketDataProvider data(data_reads, data_writes);
3198 session_deps.socket_factory.AddMockSocket(&data); 3198 session_deps.socket_factory.AddSocketDataProvider(&data);
3199 3199
3200 TestCompletionCallback callback; 3200 TestCompletionCallback callback;
3201 3201
3202 int rv = trans->Start(&request, &callback, NULL); 3202 int rv = trans->Start(&request, &callback, NULL);
3203 EXPECT_EQ(ERR_IO_PENDING, rv); 3203 EXPECT_EQ(ERR_IO_PENDING, rv);
3204 3204
3205 rv = callback.WaitForResult(); 3205 rv = callback.WaitForResult();
3206 EXPECT_EQ(OK, rv); 3206 EXPECT_EQ(OK, rv);
3207 3207
3208 const HttpResponseInfo* response = trans->GetResponseInfo(); 3208 const HttpResponseInfo* response = trans->GetResponseInfo();
(...skipping 30 matching lines...) Expand all
3239 3239
3240 MockRead data_reads[] = { 3240 MockRead data_reads[] = {
3241 MockWrite(true, reinterpret_cast<char*>(read_buffer), 3241 MockWrite(true, reinterpret_cast<char*>(read_buffer),
3242 arraysize(read_buffer)), 3242 arraysize(read_buffer)),
3243 MockRead("HTTP/1.0 200 OK\r\n"), 3243 MockRead("HTTP/1.0 200 OK\r\n"),
3244 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n\r\n"), 3244 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n\r\n"),
3245 MockRead("Payload"), 3245 MockRead("Payload"),
3246 MockRead(false, OK) 3246 MockRead(false, OK)
3247 }; 3247 };
3248 3248
3249 StaticMockSocket data(data_reads, data_writes); 3249 StaticSocketDataProvider data(data_reads, data_writes);
3250 session_deps.socket_factory.AddMockSocket(&data); 3250 session_deps.socket_factory.AddSocketDataProvider(&data);
3251 3251
3252 MockSSLSocket ssl(true, OK); 3252 SSLSocketDataProvider ssl(true, OK);
3253 session_deps.socket_factory.AddMockSSLSocket(&ssl); 3253 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl);
3254 3254
3255 TestCompletionCallback callback; 3255 TestCompletionCallback callback;
3256 3256
3257 int rv = trans->Start(&request, &callback, NULL); 3257 int rv = trans->Start(&request, &callback, NULL);
3258 EXPECT_EQ(ERR_IO_PENDING, rv); 3258 EXPECT_EQ(ERR_IO_PENDING, rv);
3259 3259
3260 rv = callback.WaitForResult(); 3260 rv = callback.WaitForResult();
3261 EXPECT_EQ(OK, rv); 3261 EXPECT_EQ(OK, rv);
3262 3262
3263 const HttpResponseInfo* response = trans->GetResponseInfo(); 3263 const HttpResponseInfo* response = trans->GetResponseInfo();
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
3298 3298
3299 MockRead data_reads[] = { 3299 MockRead data_reads[] = {
3300 MockWrite(true, kSOCKS5GreetResponse, arraysize(kSOCKS5GreetResponse)), 3300 MockWrite(true, kSOCKS5GreetResponse, arraysize(kSOCKS5GreetResponse)),
3301 MockWrite(true, kSOCKS5OkResponse, arraysize(kSOCKS5OkResponse)), 3301 MockWrite(true, kSOCKS5OkResponse, arraysize(kSOCKS5OkResponse)),
3302 MockRead("HTTP/1.0 200 OK\r\n"), 3302 MockRead("HTTP/1.0 200 OK\r\n"),
3303 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n\r\n"), 3303 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n\r\n"),
3304 MockRead("Payload"), 3304 MockRead("Payload"),
3305 MockRead(false, OK) 3305 MockRead(false, OK)
3306 }; 3306 };
3307 3307
3308 StaticMockSocket data(data_reads, data_writes); 3308 StaticSocketDataProvider data(data_reads, data_writes);
3309 session_deps.socket_factory.AddMockSocket(&data); 3309 session_deps.socket_factory.AddSocketDataProvider(&data);
3310 3310
3311 TestCompletionCallback callback; 3311 TestCompletionCallback callback;
3312 3312
3313 int rv = trans->Start(&request, &callback, NULL); 3313 int rv = trans->Start(&request, &callback, NULL);
3314 EXPECT_EQ(ERR_IO_PENDING, rv); 3314 EXPECT_EQ(ERR_IO_PENDING, rv);
3315 3315
3316 rv = callback.WaitForResult(); 3316 rv = callback.WaitForResult();
3317 EXPECT_EQ(OK, rv); 3317 EXPECT_EQ(OK, rv);
3318 3318
3319 const HttpResponseInfo* response = trans->GetResponseInfo(); 3319 const HttpResponseInfo* response = trans->GetResponseInfo();
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
3355 3355
3356 MockRead data_reads[] = { 3356 MockRead data_reads[] = {
3357 MockWrite(true, kSOCKS5GreetResponse, arraysize(kSOCKS5GreetResponse)), 3357 MockWrite(true, kSOCKS5GreetResponse, arraysize(kSOCKS5GreetResponse)),
3358 MockWrite(true, kSOCKS5OkResponse, arraysize(kSOCKS5OkResponse)), 3358 MockWrite(true, kSOCKS5OkResponse, arraysize(kSOCKS5OkResponse)),
3359 MockRead("HTTP/1.0 200 OK\r\n"), 3359 MockRead("HTTP/1.0 200 OK\r\n"),
3360 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n\r\n"), 3360 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n\r\n"),
3361 MockRead("Payload"), 3361 MockRead("Payload"),
3362 MockRead(false, OK) 3362 MockRead(false, OK)
3363 }; 3363 };
3364 3364
3365 StaticMockSocket data(data_reads, data_writes); 3365 StaticSocketDataProvider data(data_reads, data_writes);
3366 session_deps.socket_factory.AddMockSocket(&data); 3366 session_deps.socket_factory.AddSocketDataProvider(&data);
3367 3367
3368 MockSSLSocket ssl(true, OK); 3368 SSLSocketDataProvider ssl(true, OK);
3369 session_deps.socket_factory.AddMockSSLSocket(&ssl); 3369 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl);
3370 3370
3371 TestCompletionCallback callback; 3371 TestCompletionCallback callback;
3372 3372
3373 int rv = trans->Start(&request, &callback, NULL); 3373 int rv = trans->Start(&request, &callback, NULL);
3374 EXPECT_EQ(ERR_IO_PENDING, rv); 3374 EXPECT_EQ(ERR_IO_PENDING, rv);
3375 3375
3376 rv = callback.WaitForResult(); 3376 rv = callback.WaitForResult();
3377 EXPECT_EQ(OK, rv); 3377 EXPECT_EQ(OK, rv);
3378 3378
3379 const HttpResponseInfo* response = trans->GetResponseInfo(); 3379 const HttpResponseInfo* response = trans->GetResponseInfo();
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
3525 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction( 3525 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(
3526 CreateSession(&session_deps))); 3526 CreateSession(&session_deps)));
3527 3527
3528 // Attach an observer to watch the host resolutions being made. 3528 // Attach an observer to watch the host resolutions being made.
3529 session_deps.host_resolver->AddObserver(&resolution_observer); 3529 session_deps.host_resolver->AddObserver(&resolution_observer);
3530 3530
3531 // Connect up a mock socket which will fail when reading. 3531 // Connect up a mock socket which will fail when reading.
3532 MockRead data_reads[] = { 3532 MockRead data_reads[] = {
3533 MockRead(false, ERR_FAILED), 3533 MockRead(false, ERR_FAILED),
3534 }; 3534 };
3535 StaticMockSocket data(data_reads, NULL); 3535 StaticSocketDataProvider data(data_reads, NULL);
3536 session_deps.socket_factory.AddMockSocket(&data); 3536 session_deps.socket_factory.AddSocketDataProvider(&data);
3537 3537
3538 // Issue a request, containing an HTTP referrer. 3538 // Issue a request, containing an HTTP referrer.
3539 HttpRequestInfo request; 3539 HttpRequestInfo request;
3540 request.method = "GET"; 3540 request.method = "GET";
3541 request.referrer = referrer; 3541 request.referrer = referrer;
3542 request.url = GURL("http://www.google.com/"); 3542 request.url = GURL("http://www.google.com/");
3543 3543
3544 // Run the request until it fails reading from the socket. 3544 // Run the request until it fails reading from the socket.
3545 TestCompletionCallback callback; 3545 TestCompletionCallback callback;
3546 int rv = trans->Start(&request, &callback, NULL); 3546 int rv = trans->Start(&request, &callback, NULL);
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
3580 ASSERT_EQ(OK, rv); 3580 ASSERT_EQ(OK, rv);
3581 3581
3582 // Inject a failure the next time that "www.google.com" is resolved. This way 3582 // Inject a failure the next time that "www.google.com" is resolved. This way
3583 // we can tell if the next lookup hit the cache, or the "network". 3583 // we can tell if the next lookup hit the cache, or the "network".
3584 // (cache --> success, "network" --> failure). 3584 // (cache --> success, "network" --> failure).
3585 session_deps.host_resolver->rules()->AddSimulatedFailure("www.google.com"); 3585 session_deps.host_resolver->rules()->AddSimulatedFailure("www.google.com");
3586 3586
3587 // Connect up a mock socket which will fail with ERR_UNEXPECTED during the 3587 // Connect up a mock socket which will fail with ERR_UNEXPECTED during the
3588 // first read -- this won't be reached as the host resolution will fail first. 3588 // first read -- this won't be reached as the host resolution will fail first.
3589 MockRead data_reads[] = { MockRead(false, ERR_UNEXPECTED) }; 3589 MockRead data_reads[] = { MockRead(false, ERR_UNEXPECTED) };
3590 StaticMockSocket data(data_reads, NULL); 3590 StaticSocketDataProvider data(data_reads, NULL);
3591 session_deps.socket_factory.AddMockSocket(&data); 3591 session_deps.socket_factory.AddSocketDataProvider(&data);
3592 3592
3593 // Issue a request, asking to bypass the cache(s). 3593 // Issue a request, asking to bypass the cache(s).
3594 HttpRequestInfo request; 3594 HttpRequestInfo request;
3595 request.method = "GET"; 3595 request.method = "GET";
3596 request.load_flags = LOAD_BYPASS_CACHE; 3596 request.load_flags = LOAD_BYPASS_CACHE;
3597 request.url = GURL("http://www.google.com/"); 3597 request.url = GURL("http://www.google.com/");
3598 3598
3599 // Run the request. 3599 // Run the request.
3600 TestCompletionCallback callback; 3600 TestCompletionCallback callback;
3601 rv = trans->Start(&request, &callback, NULL); 3601 rv = trans->Start(&request, &callback, NULL);
(...skipping 11 matching lines...) Expand all
3613 scoped_refptr<HttpNetworkSession> session = CreateSession(&session_deps); 3613 scoped_refptr<HttpNetworkSession> session = CreateSession(&session_deps);
3614 3614
3615 HttpRequestInfo request; 3615 HttpRequestInfo request;
3616 request.method = "GET"; 3616 request.method = "GET";
3617 request.url = GURL("http://www.foo.com/"); 3617 request.url = GURL("http://www.foo.com/");
3618 request.load_flags = 0; 3618 request.load_flags = 0;
3619 3619
3620 MockWrite write_failure[] = { 3620 MockWrite write_failure[] = {
3621 MockWrite(true, ERR_CONNECTION_RESET), 3621 MockWrite(true, ERR_CONNECTION_RESET),
3622 }; 3622 };
3623 StaticMockSocket data(NULL, write_failure); 3623 StaticSocketDataProvider data(NULL, write_failure);
3624 session_deps.socket_factory.AddMockSocket(&data); 3624 session_deps.socket_factory.AddSocketDataProvider(&data);
3625 3625
3626 TestCompletionCallback callback; 3626 TestCompletionCallback callback;
3627 3627
3628 scoped_ptr<HttpTransaction> trans( 3628 scoped_ptr<HttpTransaction> trans(
3629 new HttpNetworkTransaction(CreateSession(&session_deps))); 3629 new HttpNetworkTransaction(CreateSession(&session_deps)));
3630 3630
3631 int rv = trans->Start(&request, &callback, NULL); 3631 int rv = trans->Start(&request, &callback, NULL);
3632 EXPECT_EQ(ERR_IO_PENDING, rv); 3632 EXPECT_EQ(ERR_IO_PENDING, rv);
3633 3633
3634 rv = callback.WaitForResult(); 3634 rv = callback.WaitForResult();
3635 EXPECT_EQ(ERR_CONNECTION_RESET, rv); 3635 EXPECT_EQ(ERR_CONNECTION_RESET, rv);
3636 } 3636 }
3637 3637
3638 // Check that a connection closed after the start of the headers finishes ok. 3638 // Check that a connection closed after the start of the headers finishes ok.
3639 TEST_F(HttpNetworkTransactionTest, ConnectionClosedAfterStartOfHeaders) { 3639 TEST_F(HttpNetworkTransactionTest, ConnectionClosedAfterStartOfHeaders) {
3640 SessionDependencies session_deps; 3640 SessionDependencies session_deps;
3641 scoped_refptr<HttpNetworkSession> session = CreateSession(&session_deps); 3641 scoped_refptr<HttpNetworkSession> session = CreateSession(&session_deps);
3642 3642
3643 HttpRequestInfo request; 3643 HttpRequestInfo request;
3644 request.method = "GET"; 3644 request.method = "GET";
3645 request.url = GURL("http://www.foo.com/"); 3645 request.url = GURL("http://www.foo.com/");
3646 request.load_flags = 0; 3646 request.load_flags = 0;
3647 3647
3648 MockRead data_reads[] = { 3648 MockRead data_reads[] = {
3649 MockRead("HTTP/1."), 3649 MockRead("HTTP/1."),
3650 MockRead(false, OK), 3650 MockRead(false, OK),
3651 }; 3651 };
3652 3652
3653 StaticMockSocket data(data_reads, NULL); 3653 StaticSocketDataProvider data(data_reads, NULL);
3654 session_deps.socket_factory.AddMockSocket(&data); 3654 session_deps.socket_factory.AddSocketDataProvider(&data);
3655 3655
3656 TestCompletionCallback callback; 3656 TestCompletionCallback callback;
3657 3657
3658 scoped_ptr<HttpTransaction> trans( 3658 scoped_ptr<HttpTransaction> trans(
3659 new HttpNetworkTransaction(CreateSession(&session_deps))); 3659 new HttpNetworkTransaction(CreateSession(&session_deps)));
3660 3660
3661 int rv = trans->Start(&request, &callback, NULL); 3661 int rv = trans->Start(&request, &callback, NULL);
3662 EXPECT_EQ(ERR_IO_PENDING, rv); 3662 EXPECT_EQ(ERR_IO_PENDING, rv);
3663 3663
3664 rv = callback.WaitForResult(); 3664 rv = callback.WaitForResult();
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
3696 3696
3697 MockRead data_reads1[] = { 3697 MockRead data_reads1[] = {
3698 MockRead("HTTP/1.1 401 Unauthorized\r\n"), 3698 MockRead("HTTP/1.1 401 Unauthorized\r\n"),
3699 MockRead("WWW-Authenticate: Basic realm=\"MyRealm1\"\r\n"), 3699 MockRead("WWW-Authenticate: Basic realm=\"MyRealm1\"\r\n"),
3700 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n"), 3700 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n"),
3701 MockRead("Content-Length: 14\r\n\r\n"), 3701 MockRead("Content-Length: 14\r\n\r\n"),
3702 MockRead("Unauth"), 3702 MockRead("Unauth"),
3703 MockRead(true, ERR_CONNECTION_RESET), 3703 MockRead(true, ERR_CONNECTION_RESET),
3704 }; 3704 };
3705 3705
3706 StaticMockSocket data1(data_reads1, data_writes1); 3706 StaticSocketDataProvider data1(data_reads1, data_writes1);
3707 session_deps.socket_factory.AddMockSocket(&data1); 3707 session_deps.socket_factory.AddSocketDataProvider(&data1);
3708 3708
3709 // After calling trans->RestartWithAuth(), this is the request we should 3709 // After calling trans->RestartWithAuth(), this is the request we should
3710 // be issuing -- the final header line contains the credentials. 3710 // be issuing -- the final header line contains the credentials.
3711 MockWrite data_writes2[] = { 3711 MockWrite data_writes2[] = {
3712 MockWrite("GET / HTTP/1.1\r\n" 3712 MockWrite("GET / HTTP/1.1\r\n"
3713 "Host: www.google.com\r\n" 3713 "Host: www.google.com\r\n"
3714 "Connection: keep-alive\r\n" 3714 "Connection: keep-alive\r\n"
3715 "Authorization: Basic Zm9vOmJhcg==\r\n\r\n"), 3715 "Authorization: Basic Zm9vOmJhcg==\r\n\r\n"),
3716 }; 3716 };
3717 3717
3718 // Lastly, the server responds with the actual content. 3718 // Lastly, the server responds with the actual content.
3719 MockRead data_reads2[] = { 3719 MockRead data_reads2[] = {
3720 MockRead("HTTP/1.1 200 OK\r\n"), 3720 MockRead("HTTP/1.1 200 OK\r\n"),
3721 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n"), 3721 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n"),
3722 MockRead("Content-Length: 100\r\n\r\n"), 3722 MockRead("Content-Length: 100\r\n\r\n"),
3723 MockRead(false, OK), 3723 MockRead(false, OK),
3724 }; 3724 };
3725 3725
3726 StaticMockSocket data2(data_reads2, data_writes2); 3726 StaticSocketDataProvider data2(data_reads2, data_writes2);
3727 session_deps.socket_factory.AddMockSocket(&data2); 3727 session_deps.socket_factory.AddSocketDataProvider(&data2);
3728 3728
3729 TestCompletionCallback callback1; 3729 TestCompletionCallback callback1;
3730 3730
3731 int rv = trans->Start(&request, &callback1, NULL); 3731 int rv = trans->Start(&request, &callback1, NULL);
3732 EXPECT_EQ(ERR_IO_PENDING, rv); 3732 EXPECT_EQ(ERR_IO_PENDING, rv);
3733 3733
3734 rv = callback1.WaitForResult(); 3734 rv = callback1.WaitForResult();
3735 EXPECT_EQ(OK, rv); 3735 EXPECT_EQ(OK, rv);
3736 3736
3737 const HttpResponseInfo* response = trans->GetResponseInfo(); 3737 const HttpResponseInfo* response = trans->GetResponseInfo();
(...skipping 27 matching lines...) Expand all
3765 HttpRequestInfo request; 3765 HttpRequestInfo request;
3766 request.method = "GET"; 3766 request.method = "GET";
3767 request.url = GURL("https://www.google.com/"); 3767 request.url = GURL("https://www.google.com/");
3768 request.load_flags = 0; 3768 request.load_flags = 0;
3769 3769
3770 MockRead proxy_reads[] = { 3770 MockRead proxy_reads[] = {
3771 MockRead("HTTP/1.0 200 Connected\r\n\r\nExtra data"), 3771 MockRead("HTTP/1.0 200 Connected\r\n\r\nExtra data"),
3772 MockRead(false, OK) 3772 MockRead(false, OK)
3773 }; 3773 };
3774 3774
3775 StaticMockSocket data(proxy_reads, NULL); 3775 StaticSocketDataProvider data(proxy_reads, NULL);
3776 MockSSLSocket ssl(true, OK); 3776 SSLSocketDataProvider ssl(true, OK);
3777 3777
3778 session_deps.socket_factory.AddMockSocket(&data); 3778 session_deps.socket_factory.AddSocketDataProvider(&data);
3779 session_deps.socket_factory.AddMockSSLSocket(&ssl); 3779 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl);
3780 3780
3781 TestCompletionCallback callback; 3781 TestCompletionCallback callback;
3782 3782
3783 session_deps.socket_factory.ResetNextMockIndexes(); 3783 session_deps.socket_factory.ResetNextMockIndexes();
3784 3784
3785 scoped_ptr<HttpTransaction> trans( 3785 scoped_ptr<HttpTransaction> trans(
3786 new HttpNetworkTransaction(CreateSession(&session_deps))); 3786 new HttpNetworkTransaction(CreateSession(&session_deps)));
3787 3787
3788 int rv = trans->Start(&request, &callback, NULL); 3788 int rv = trans->Start(&request, &callback, NULL);
3789 EXPECT_EQ(ERR_IO_PENDING, rv); 3789 EXPECT_EQ(ERR_IO_PENDING, rv);
3790 3790
3791 rv = callback.WaitForResult(); 3791 rv = callback.WaitForResult();
3792 EXPECT_EQ(ERR_TUNNEL_CONNECTION_FAILED, rv); 3792 EXPECT_EQ(ERR_TUNNEL_CONNECTION_FAILED, rv);
3793 } 3793 }
3794 3794
3795 } // namespace net 3795 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_network_layer_unittest.cc ('k') | net/socket/socket_test_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698