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

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

Issue 126303: Add a "LoadLog*" parameter to transactions, hostresolver, clientsocketpool. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: sync again Created 11 years, 4 months 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_transaction.cc ('k') | net/http/http_transaction.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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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_info.h" 10 #include "net/base/ssl_info.h"
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 HttpRequestInfo request; 89 HttpRequestInfo request;
90 request.method = "GET"; 90 request.method = "GET";
91 request.url = GURL("http://www.google.com/"); 91 request.url = GURL("http://www.google.com/");
92 request.load_flags = 0; 92 request.load_flags = 0;
93 93
94 StaticMockSocket data(data_reads, NULL); 94 StaticMockSocket data(data_reads, NULL);
95 session_deps.socket_factory.AddMockSocket(&data); 95 session_deps.socket_factory.AddMockSocket(&data);
96 96
97 TestCompletionCallback callback; 97 TestCompletionCallback callback;
98 98
99 int rv = trans->Start(&request, &callback); 99 int rv = trans->Start(NULL, &request, &callback);
100 EXPECT_EQ(ERR_IO_PENDING, rv); 100 EXPECT_EQ(ERR_IO_PENDING, rv);
101 101
102 out.rv = callback.WaitForResult(); 102 out.rv = callback.WaitForResult();
103 if (out.rv != OK) 103 if (out.rv != OK)
104 return out; 104 return out;
105 105
106 const HttpResponseInfo* response = trans->GetResponseInfo(); 106 const HttpResponseInfo* response = trans->GetResponseInfo();
107 EXPECT_TRUE(response != NULL); 107 EXPECT_TRUE(response != NULL);
108 108
109 EXPECT_TRUE(response->headers != NULL); 109 EXPECT_TRUE(response->headers != NULL);
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 } 162 }
163 163
164 std::string MockGetHostName() { 164 std::string MockGetHostName() {
165 return "WTC-WIN7"; 165 return "WTC-WIN7";
166 } 166 }
167 167
168 class CaptureGroupNameSocketPool : public ClientSocketPool { 168 class CaptureGroupNameSocketPool : public ClientSocketPool {
169 public: 169 public:
170 CaptureGroupNameSocketPool() { 170 CaptureGroupNameSocketPool() {
171 } 171 }
172 virtual int RequestSocket(const std::string& group_name, 172 virtual int RequestSocket(LoadLog* load_log,
173 const std::string& group_name,
173 const HostResolver::RequestInfo& resolve_info, 174 const HostResolver::RequestInfo& resolve_info,
174 int priority, 175 int priority,
175 ClientSocketHandle* handle, 176 ClientSocketHandle* handle,
176 CompletionCallback* callback) { 177 CompletionCallback* callback) {
177 last_group_name_ = group_name; 178 last_group_name_ = group_name;
178 return ERR_IO_PENDING; 179 return ERR_IO_PENDING;
179 } 180 }
180 181
181 const std::string last_group_name_received() const { 182 const std::string last_group_name_received() const {
182 return last_group_name_; 183 return last_group_name_;
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 345
345 // No response body because the test stops reading here. 346 // No response body because the test stops reading here.
346 MockRead(false, ERR_UNEXPECTED), // Should not be reached. 347 MockRead(false, ERR_UNEXPECTED), // Should not be reached.
347 }; 348 };
348 349
349 StaticMockSocket data1(data_reads1, data_writes1); 350 StaticMockSocket data1(data_reads1, data_writes1);
350 session_deps.socket_factory.AddMockSocket(&data1); 351 session_deps.socket_factory.AddMockSocket(&data1);
351 352
352 TestCompletionCallback callback1; 353 TestCompletionCallback callback1;
353 354
354 int rv = trans->Start(&request, &callback1); 355 int rv = trans->Start(NULL, &request, &callback1);
355 EXPECT_EQ(ERR_IO_PENDING, rv); 356 EXPECT_EQ(ERR_IO_PENDING, rv);
356 357
357 rv = callback1.WaitForResult(); 358 rv = callback1.WaitForResult();
358 EXPECT_EQ(OK, rv); 359 EXPECT_EQ(OK, rv);
359 360
360 const HttpResponseInfo* response = trans->GetResponseInfo(); 361 const HttpResponseInfo* response = trans->GetResponseInfo();
361 EXPECT_FALSE(response == NULL); 362 EXPECT_FALSE(response == NULL);
362 363
363 // Check that the headers got parsed. 364 // Check that the headers got parsed.
364 EXPECT_TRUE(response->headers != NULL); 365 EXPECT_TRUE(response->headers != NULL);
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 scoped_ptr<HttpTransaction> trans( 403 scoped_ptr<HttpTransaction> trans(
403 new HttpNetworkTransaction(session, &session_deps.socket_factory)); 404 new HttpNetworkTransaction(session, &session_deps.socket_factory));
404 405
405 HttpRequestInfo request; 406 HttpRequestInfo request;
406 request.method = "GET"; 407 request.method = "GET";
407 request.url = GURL("http://www.google.com/"); 408 request.url = GURL("http://www.google.com/");
408 request.load_flags = 0; 409 request.load_flags = 0;
409 410
410 TestCompletionCallback callback; 411 TestCompletionCallback callback;
411 412
412 int rv = trans->Start(&request, &callback); 413 int rv = trans->Start(NULL, &request, &callback);
413 EXPECT_EQ(ERR_IO_PENDING, rv); 414 EXPECT_EQ(ERR_IO_PENDING, rv);
414 415
415 rv = callback.WaitForResult(); 416 rv = callback.WaitForResult();
416 EXPECT_EQ(OK, rv); 417 EXPECT_EQ(OK, rv);
417 418
418 const HttpResponseInfo* response = trans->GetResponseInfo(); 419 const HttpResponseInfo* response = trans->GetResponseInfo();
419 EXPECT_TRUE(response != NULL); 420 EXPECT_TRUE(response != NULL);
420 421
421 EXPECT_TRUE(response->headers != NULL); 422 EXPECT_TRUE(response->headers != NULL);
422 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); 423 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine());
(...skipping 23 matching lines...) Expand all
446 MockRead("HTTP/1.0 100 Continue\r\n\r\n"), 447 MockRead("HTTP/1.0 100 Continue\r\n\r\n"),
447 MockRead("HTTP/1.0 200 OK\r\n\r\n"), 448 MockRead("HTTP/1.0 200 OK\r\n\r\n"),
448 MockRead("hello world"), 449 MockRead("hello world"),
449 MockRead(false, OK), 450 MockRead(false, OK),
450 }; 451 };
451 StaticMockSocket data(data_reads, NULL); 452 StaticMockSocket data(data_reads, NULL);
452 session_deps.socket_factory.AddMockSocket(&data); 453 session_deps.socket_factory.AddMockSocket(&data);
453 454
454 TestCompletionCallback callback; 455 TestCompletionCallback callback;
455 456
456 int rv = trans->Start(&request, &callback); 457 int rv = trans->Start(NULL, &request, &callback);
457 EXPECT_EQ(ERR_IO_PENDING, rv); 458 EXPECT_EQ(ERR_IO_PENDING, rv);
458 459
459 rv = callback.WaitForResult(); 460 rv = callback.WaitForResult();
460 EXPECT_EQ(OK, rv); 461 EXPECT_EQ(OK, rv);
461 462
462 const HttpResponseInfo* response = trans->GetResponseInfo(); 463 const HttpResponseInfo* response = trans->GetResponseInfo();
463 EXPECT_TRUE(response != NULL); 464 EXPECT_TRUE(response != NULL);
464 465
465 EXPECT_TRUE(response->headers != NULL); 466 EXPECT_TRUE(response->headers != NULL);
466 EXPECT_EQ("HTTP/1.0 200 OK", response->headers->GetStatusLine()); 467 EXPECT_EQ("HTTP/1.0 200 OK", response->headers->GetStatusLine());
(...skipping 23 matching lines...) Expand all
490 MockRead("HTTP/1.1 102 Unspecified status code\r\n\r\n"), 491 MockRead("HTTP/1.1 102 Unspecified status code\r\n\r\n"),
491 MockRead("HTTP/1.1 200 OK\r\n\r\n"), 492 MockRead("HTTP/1.1 200 OK\r\n\r\n"),
492 MockRead("hello world"), 493 MockRead("hello world"),
493 MockRead(false, OK), 494 MockRead(false, OK),
494 }; 495 };
495 StaticMockSocket data(data_reads, NULL); 496 StaticMockSocket data(data_reads, NULL);
496 session_deps.socket_factory.AddMockSocket(&data); 497 session_deps.socket_factory.AddMockSocket(&data);
497 498
498 TestCompletionCallback callback; 499 TestCompletionCallback callback;
499 500
500 int rv = trans->Start(&request, &callback); 501 int rv = trans->Start(NULL, &request, &callback);
501 EXPECT_EQ(ERR_IO_PENDING, rv); 502 EXPECT_EQ(ERR_IO_PENDING, rv);
502 503
503 rv = callback.WaitForResult(); 504 rv = callback.WaitForResult();
504 EXPECT_EQ(OK, rv); 505 EXPECT_EQ(OK, rv);
505 506
506 const HttpResponseInfo* response = trans->GetResponseInfo(); 507 const HttpResponseInfo* response = trans->GetResponseInfo();
507 EXPECT_TRUE(response != NULL); 508 EXPECT_TRUE(response != NULL);
508 509
509 EXPECT_TRUE(response->headers != NULL); 510 EXPECT_TRUE(response->headers != NULL);
510 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); 511 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine());
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
546 const char* kExpectedResponseData[] = { 547 const char* kExpectedResponseData[] = {
547 "hello", "world" 548 "hello", "world"
548 }; 549 };
549 550
550 for (int i = 0; i < 2; ++i) { 551 for (int i = 0; i < 2; ++i) {
551 TestCompletionCallback callback; 552 TestCompletionCallback callback;
552 553
553 scoped_ptr<HttpTransaction> trans( 554 scoped_ptr<HttpTransaction> trans(
554 new HttpNetworkTransaction(session, &session_deps.socket_factory)); 555 new HttpNetworkTransaction(session, &session_deps.socket_factory));
555 556
556 int rv = trans->Start(&request, &callback); 557 int rv = trans->Start(NULL, &request, &callback);
557 EXPECT_EQ(ERR_IO_PENDING, rv); 558 EXPECT_EQ(ERR_IO_PENDING, rv);
558 559
559 rv = callback.WaitForResult(); 560 rv = callback.WaitForResult();
560 EXPECT_EQ(OK, rv); 561 EXPECT_EQ(OK, rv);
561 562
562 const HttpResponseInfo* response = trans->GetResponseInfo(); 563 const HttpResponseInfo* response = trans->GetResponseInfo();
563 EXPECT_TRUE(response != NULL); 564 EXPECT_TRUE(response != NULL);
564 565
565 EXPECT_TRUE(response->headers != NULL); 566 EXPECT_TRUE(response->headers != NULL);
566 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); 567 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine());
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
598 MockRead(true, ERR_CONNECTION_RESET), 599 MockRead(true, ERR_CONNECTION_RESET),
599 MockRead("HTTP/1.0 200 OK\r\n\r\n"), // Should not be used 600 MockRead("HTTP/1.0 200 OK\r\n\r\n"), // Should not be used
600 MockRead("hello world"), 601 MockRead("hello world"),
601 MockRead(false, OK), 602 MockRead(false, OK),
602 }; 603 };
603 StaticMockSocket data(data_reads, NULL); 604 StaticMockSocket data(data_reads, NULL);
604 session_deps.socket_factory.AddMockSocket(&data); 605 session_deps.socket_factory.AddMockSocket(&data);
605 606
606 TestCompletionCallback callback; 607 TestCompletionCallback callback;
607 608
608 int rv = trans->Start(&request, &callback); 609 int rv = trans->Start(NULL, &request, &callback);
609 EXPECT_EQ(ERR_IO_PENDING, rv); 610 EXPECT_EQ(ERR_IO_PENDING, rv);
610 611
611 rv = callback.WaitForResult(); 612 rv = callback.WaitForResult();
612 EXPECT_EQ(ERR_CONNECTION_RESET, rv); 613 EXPECT_EQ(ERR_CONNECTION_RESET, rv);
613 614
614 const HttpResponseInfo* response = trans->GetResponseInfo(); 615 const HttpResponseInfo* response = trans->GetResponseInfo();
615 EXPECT_TRUE(response == NULL); 616 EXPECT_TRUE(response == NULL);
616 } 617 }
617 618
618 // What do various browsers do when the server closes a non-keepalive 619 // What do various browsers do when the server closes a non-keepalive
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
685 MockRead(false, OK), 686 MockRead(false, OK),
686 }; 687 };
687 688
688 StaticMockSocket data1(data_reads1, data_writes1); 689 StaticMockSocket data1(data_reads1, data_writes1);
689 StaticMockSocket data2(data_reads2, data_writes2); 690 StaticMockSocket data2(data_reads2, data_writes2);
690 session_deps.socket_factory.AddMockSocket(&data1); 691 session_deps.socket_factory.AddMockSocket(&data1);
691 session_deps.socket_factory.AddMockSocket(&data2); 692 session_deps.socket_factory.AddMockSocket(&data2);
692 693
693 TestCompletionCallback callback1; 694 TestCompletionCallback callback1;
694 695
695 int rv = trans->Start(&request, &callback1); 696 int rv = trans->Start(NULL, &request, &callback1);
696 EXPECT_EQ(ERR_IO_PENDING, rv); 697 EXPECT_EQ(ERR_IO_PENDING, rv);
697 698
698 rv = callback1.WaitForResult(); 699 rv = callback1.WaitForResult();
699 EXPECT_EQ(OK, rv); 700 EXPECT_EQ(OK, rv);
700 701
701 const HttpResponseInfo* response = trans->GetResponseInfo(); 702 const HttpResponseInfo* response = trans->GetResponseInfo();
702 EXPECT_FALSE(response == NULL); 703 EXPECT_FALSE(response == NULL);
703 704
704 // The password prompt info should have been set in response->auth_challenge. 705 // The password prompt info should have been set in response->auth_challenge.
705 EXPECT_FALSE(response->auth_challenge.get() == NULL); 706 EXPECT_FALSE(response->auth_challenge.get() == NULL);
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
761 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n"), 762 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n"),
762 MockRead("Content-Length: 100\r\n\r\n"), 763 MockRead("Content-Length: 100\r\n\r\n"),
763 MockRead(false, OK), 764 MockRead(false, OK),
764 }; 765 };
765 766
766 StaticMockSocket data1(data_reads1, data_writes1); 767 StaticMockSocket data1(data_reads1, data_writes1);
767 session_deps.socket_factory.AddMockSocket(&data1); 768 session_deps.socket_factory.AddMockSocket(&data1);
768 769
769 TestCompletionCallback callback1; 770 TestCompletionCallback callback1;
770 771
771 int rv = trans->Start(&request, &callback1); 772 int rv = trans->Start(NULL, &request, &callback1);
772 EXPECT_EQ(ERR_IO_PENDING, rv); 773 EXPECT_EQ(ERR_IO_PENDING, rv);
773 774
774 rv = callback1.WaitForResult(); 775 rv = callback1.WaitForResult();
775 EXPECT_EQ(OK, rv); 776 EXPECT_EQ(OK, rv);
776 777
777 const HttpResponseInfo* response = trans->GetResponseInfo(); 778 const HttpResponseInfo* response = trans->GetResponseInfo();
778 EXPECT_FALSE(response == NULL); 779 EXPECT_FALSE(response == NULL);
779 780
780 // The password prompt info should have been set in response->auth_challenge. 781 // The password prompt info should have been set in response->auth_challenge.
781 EXPECT_FALSE(response->auth_challenge.get() == NULL); 782 EXPECT_FALSE(response->auth_challenge.get() == NULL);
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
840 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n"), 841 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n"),
841 MockRead("Content-Length: 100\r\n\r\n"), 842 MockRead("Content-Length: 100\r\n\r\n"),
842 MockRead(false, OK), 843 MockRead(false, OK),
843 }; 844 };
844 845
845 StaticMockSocket data1(data_reads1, data_writes1); 846 StaticMockSocket data1(data_reads1, data_writes1);
846 session_deps.socket_factory.AddMockSocket(&data1); 847 session_deps.socket_factory.AddMockSocket(&data1);
847 848
848 TestCompletionCallback callback1; 849 TestCompletionCallback callback1;
849 850
850 int rv = trans->Start(&request, &callback1); 851 int rv = trans->Start(NULL, &request, &callback1);
851 EXPECT_EQ(ERR_IO_PENDING, rv); 852 EXPECT_EQ(ERR_IO_PENDING, rv);
852 853
853 rv = callback1.WaitForResult(); 854 rv = callback1.WaitForResult();
854 EXPECT_EQ(OK, rv); 855 EXPECT_EQ(OK, rv);
855 856
856 const HttpResponseInfo* response = trans->GetResponseInfo(); 857 const HttpResponseInfo* response = trans->GetResponseInfo();
857 EXPECT_FALSE(response == NULL); 858 EXPECT_FALSE(response == NULL);
858 859
859 // The password prompt info should have been set in response->auth_challenge. 860 // The password prompt info should have been set in response->auth_challenge.
860 EXPECT_FALSE(response->auth_challenge.get() == NULL); 861 EXPECT_FALSE(response->auth_challenge.get() == NULL);
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
922 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n"), 923 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n"),
923 MockRead("Content-Length: 100\r\n\r\n"), 924 MockRead("Content-Length: 100\r\n\r\n"),
924 MockRead(false, OK), 925 MockRead(false, OK),
925 }; 926 };
926 927
927 StaticMockSocket data1(data_reads1, data_writes1); 928 StaticMockSocket data1(data_reads1, data_writes1);
928 session_deps.socket_factory.AddMockSocket(&data1); 929 session_deps.socket_factory.AddMockSocket(&data1);
929 930
930 TestCompletionCallback callback1; 931 TestCompletionCallback callback1;
931 932
932 int rv = trans->Start(&request, &callback1); 933 int rv = trans->Start(NULL, &request, &callback1);
933 EXPECT_EQ(ERR_IO_PENDING, rv); 934 EXPECT_EQ(ERR_IO_PENDING, rv);
934 935
935 rv = callback1.WaitForResult(); 936 rv = callback1.WaitForResult();
936 EXPECT_EQ(OK, rv); 937 EXPECT_EQ(OK, rv);
937 938
938 const HttpResponseInfo* response = trans->GetResponseInfo(); 939 const HttpResponseInfo* response = trans->GetResponseInfo();
939 EXPECT_FALSE(response == NULL); 940 EXPECT_FALSE(response == NULL);
940 941
941 // The password prompt info should have been set in response->auth_challenge. 942 // The password prompt info should have been set in response->auth_challenge.
942 EXPECT_FALSE(response->auth_challenge.get() == NULL); 943 EXPECT_FALSE(response->auth_challenge.get() == NULL);
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
1003 MockRead("Content-Length: 10\r\n\r\n"), 1004 MockRead("Content-Length: 10\r\n\r\n"),
1004 // No response body because the test stops reading here. 1005 // No response body because the test stops reading here.
1005 MockRead(false, ERR_UNEXPECTED), // Should not be reached. 1006 MockRead(false, ERR_UNEXPECTED), // Should not be reached.
1006 }; 1007 };
1007 1008
1008 StaticMockSocket data1(data_reads1, data_writes1); 1009 StaticMockSocket data1(data_reads1, data_writes1);
1009 session_deps.socket_factory.AddMockSocket(&data1); 1010 session_deps.socket_factory.AddMockSocket(&data1);
1010 1011
1011 TestCompletionCallback callback1; 1012 TestCompletionCallback callback1;
1012 1013
1013 int rv = trans->Start(&request, &callback1); 1014 int rv = trans->Start(NULL, &request, &callback1);
1014 EXPECT_EQ(ERR_IO_PENDING, rv); 1015 EXPECT_EQ(ERR_IO_PENDING, rv);
1015 1016
1016 rv = callback1.WaitForResult(); 1017 rv = callback1.WaitForResult();
1017 EXPECT_EQ(OK, rv); 1018 EXPECT_EQ(OK, rv);
1018 1019
1019 const HttpResponseInfo* response = trans->GetResponseInfo(); 1020 const HttpResponseInfo* response = trans->GetResponseInfo();
1020 EXPECT_FALSE(response == NULL); 1021 EXPECT_FALSE(response == NULL);
1021 1022
1022 EXPECT_TRUE(response->headers->IsKeepAlive()); 1023 EXPECT_TRUE(response->headers->IsKeepAlive());
1023 EXPECT_EQ(407, response->headers->response_code()); 1024 EXPECT_EQ(407, response->headers->response_code());
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
1085 MockRead("Proxy-Authenticate: Basic realm=\"MyRealm1\"\r\n"), 1086 MockRead("Proxy-Authenticate: Basic realm=\"MyRealm1\"\r\n"),
1086 MockRead("Content-Length: 10\r\n\r\n"), 1087 MockRead("Content-Length: 10\r\n\r\n"),
1087 MockRead(false, ERR_UNEXPECTED), // Should not be reached. 1088 MockRead(false, ERR_UNEXPECTED), // Should not be reached.
1088 }; 1089 };
1089 1090
1090 StaticMockSocket data(data_reads, data_writes); 1091 StaticMockSocket data(data_reads, data_writes);
1091 session_deps.socket_factory.AddMockSocket(&data); 1092 session_deps.socket_factory.AddMockSocket(&data);
1092 1093
1093 TestCompletionCallback callback; 1094 TestCompletionCallback callback;
1094 1095
1095 int rv = trans->Start(&request, &callback); 1096 int rv = trans->Start(NULL, &request, &callback);
1096 EXPECT_EQ(ERR_IO_PENDING, rv); 1097 EXPECT_EQ(ERR_IO_PENDING, rv);
1097 1098
1098 rv = callback.WaitForResult(); 1099 rv = callback.WaitForResult();
1099 EXPECT_EQ(OK, rv); 1100 EXPECT_EQ(OK, rv);
1100 1101
1101 const HttpResponseInfo* response = trans->GetResponseInfo(); 1102 const HttpResponseInfo* response = trans->GetResponseInfo();
1102 EXPECT_FALSE(response == NULL); 1103 EXPECT_FALSE(response == NULL);
1103 1104
1104 EXPECT_TRUE(response->headers->IsKeepAlive()); 1105 EXPECT_TRUE(response->headers->IsKeepAlive());
1105 EXPECT_EQ(407, response->headers->response_code()); 1106 EXPECT_EQ(407, response->headers->response_code());
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1138 MockRead("Content-Length: 10\r\n\r\n"), 1139 MockRead("Content-Length: 10\r\n\r\n"),
1139 // No response body because the test stops reading here. 1140 // No response body because the test stops reading here.
1140 MockRead(false, ERR_UNEXPECTED), // Should not be reached. 1141 MockRead(false, ERR_UNEXPECTED), // Should not be reached.
1141 }; 1142 };
1142 1143
1143 StaticMockSocket data(data_reads, data_writes); 1144 StaticMockSocket data(data_reads, data_writes);
1144 session_deps.socket_factory.AddMockSocket(&data); 1145 session_deps.socket_factory.AddMockSocket(&data);
1145 1146
1146 TestCompletionCallback callback; 1147 TestCompletionCallback callback;
1147 1148
1148 int rv = trans->Start(&request, &callback); 1149 int rv = trans->Start(NULL, &request, &callback);
1149 EXPECT_EQ(ERR_IO_PENDING, rv); 1150 EXPECT_EQ(ERR_IO_PENDING, rv);
1150 1151
1151 rv = callback.WaitForResult(); 1152 rv = callback.WaitForResult();
1152 EXPECT_EQ(expected_status, rv); 1153 EXPECT_EQ(expected_status, rv);
1153 } 1154 }
1154 1155
1155 void HttpNetworkTransactionTest::ConnectStatusHelper(const MockRead& status) { 1156 void HttpNetworkTransactionTest::ConnectStatusHelper(const MockRead& status) {
1156 ConnectStatusHelperWithExpectedStatus( 1157 ConnectStatusHelperWithExpectedStatus(
1157 status, ERR_TUNNEL_CONNECTION_FAILED); 1158 status, ERR_TUNNEL_CONNECTION_FAILED);
1158 } 1159 }
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
1398 1399
1399 StaticMockSocket data1(data_reads1, data_writes1); 1400 StaticMockSocket data1(data_reads1, data_writes1);
1400 StaticMockSocket data2(data_reads2, data_writes2); 1401 StaticMockSocket data2(data_reads2, data_writes2);
1401 StaticMockSocket data3(data_reads3, data_writes3); 1402 StaticMockSocket data3(data_reads3, data_writes3);
1402 session_deps.socket_factory.AddMockSocket(&data1); 1403 session_deps.socket_factory.AddMockSocket(&data1);
1403 session_deps.socket_factory.AddMockSocket(&data2); 1404 session_deps.socket_factory.AddMockSocket(&data2);
1404 session_deps.socket_factory.AddMockSocket(&data3); 1405 session_deps.socket_factory.AddMockSocket(&data3);
1405 1406
1406 TestCompletionCallback callback1; 1407 TestCompletionCallback callback1;
1407 1408
1408 int rv = trans->Start(&request, &callback1); 1409 int rv = trans->Start(NULL, &request, &callback1);
1409 EXPECT_EQ(ERR_IO_PENDING, rv); 1410 EXPECT_EQ(ERR_IO_PENDING, rv);
1410 1411
1411 rv = callback1.WaitForResult(); 1412 rv = callback1.WaitForResult();
1412 EXPECT_EQ(OK, rv); 1413 EXPECT_EQ(OK, rv);
1413 1414
1414 const HttpResponseInfo* response = trans->GetResponseInfo(); 1415 const HttpResponseInfo* response = trans->GetResponseInfo();
1415 EXPECT_FALSE(response == NULL); 1416 EXPECT_FALSE(response == NULL);
1416 1417
1417 // The password prompt info should have been set in response->auth_challenge. 1418 // The password prompt info should have been set in response->auth_challenge.
1418 EXPECT_FALSE(response->auth_challenge.get() == NULL); 1419 EXPECT_FALSE(response->auth_challenge.get() == NULL);
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
1533 MockRead(false, OK), 1534 MockRead(false, OK),
1534 }; 1535 };
1535 1536
1536 StaticMockSocket data1(data_reads1, data_writes1); 1537 StaticMockSocket data1(data_reads1, data_writes1);
1537 StaticMockSocket data2(data_reads2, data_writes2); 1538 StaticMockSocket data2(data_reads2, data_writes2);
1538 session_deps.socket_factory.AddMockSocket(&data1); 1539 session_deps.socket_factory.AddMockSocket(&data1);
1539 session_deps.socket_factory.AddMockSocket(&data2); 1540 session_deps.socket_factory.AddMockSocket(&data2);
1540 1541
1541 TestCompletionCallback callback1; 1542 TestCompletionCallback callback1;
1542 1543
1543 int rv = trans->Start(&request, &callback1); 1544 int rv = trans->Start(NULL, &request, &callback1);
1544 EXPECT_EQ(ERR_IO_PENDING, rv); 1545 EXPECT_EQ(ERR_IO_PENDING, rv);
1545 1546
1546 rv = callback1.WaitForResult(); 1547 rv = callback1.WaitForResult();
1547 EXPECT_EQ(OK, rv); 1548 EXPECT_EQ(OK, rv);
1548 1549
1549 EXPECT_TRUE(trans->IsReadyToRestartForAuth()); 1550 EXPECT_TRUE(trans->IsReadyToRestartForAuth());
1550 TestCompletionCallback callback2; 1551 TestCompletionCallback callback2;
1551 rv = trans->RestartWithAuth(std::wstring(), std::wstring(), &callback2); 1552 rv = trans->RestartWithAuth(std::wstring(), std::wstring(), &callback2);
1552 EXPECT_EQ(ERR_IO_PENDING, rv); 1553 EXPECT_EQ(ERR_IO_PENDING, rv);
1553 rv = callback2.WaitForResult(); 1554 rv = callback2.WaitForResult();
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
1707 1708
1708 StaticMockSocket data1(data_reads1, data_writes1); 1709 StaticMockSocket data1(data_reads1, data_writes1);
1709 StaticMockSocket data2(data_reads2, data_writes2); 1710 StaticMockSocket data2(data_reads2, data_writes2);
1710 StaticMockSocket data3(data_reads3, data_writes3); 1711 StaticMockSocket data3(data_reads3, data_writes3);
1711 session_deps.socket_factory.AddMockSocket(&data1); 1712 session_deps.socket_factory.AddMockSocket(&data1);
1712 session_deps.socket_factory.AddMockSocket(&data2); 1713 session_deps.socket_factory.AddMockSocket(&data2);
1713 session_deps.socket_factory.AddMockSocket(&data3); 1714 session_deps.socket_factory.AddMockSocket(&data3);
1714 1715
1715 TestCompletionCallback callback1; 1716 TestCompletionCallback callback1;
1716 1717
1717 int rv = trans->Start(&request, &callback1); 1718 int rv = trans->Start(NULL, &request, &callback1);
1718 EXPECT_EQ(ERR_IO_PENDING, rv); 1719 EXPECT_EQ(ERR_IO_PENDING, rv);
1719 1720
1720 rv = callback1.WaitForResult(); 1721 rv = callback1.WaitForResult();
1721 EXPECT_EQ(OK, rv); 1722 EXPECT_EQ(OK, rv);
1722 1723
1723 EXPECT_TRUE(trans->IsReadyToRestartForAuth()); 1724 EXPECT_TRUE(trans->IsReadyToRestartForAuth());
1724 TestCompletionCallback callback2; 1725 TestCompletionCallback callback2;
1725 rv = trans->RestartWithAuth(std::wstring(), std::wstring(), &callback2); 1726 rv = trans->RestartWithAuth(std::wstring(), std::wstring(), &callback2);
1726 EXPECT_EQ(ERR_IO_PENDING, rv); 1727 EXPECT_EQ(ERR_IO_PENDING, rv);
1727 rv = callback2.WaitForResult(); 1728 rv = callback2.WaitForResult();
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
1802 MockRead("HTTP/1.0 200 OK\r\n"), 1803 MockRead("HTTP/1.0 200 OK\r\n"),
1803 MockRead(true, large_headers_string.data(), large_headers_string.size()), 1804 MockRead(true, large_headers_string.data(), large_headers_string.size()),
1804 MockRead("\r\nBODY"), 1805 MockRead("\r\nBODY"),
1805 MockRead(false, OK), 1806 MockRead(false, OK),
1806 }; 1807 };
1807 StaticMockSocket data(data_reads, NULL); 1808 StaticMockSocket data(data_reads, NULL);
1808 session_deps.socket_factory.AddMockSocket(&data); 1809 session_deps.socket_factory.AddMockSocket(&data);
1809 1810
1810 TestCompletionCallback callback; 1811 TestCompletionCallback callback;
1811 1812
1812 int rv = trans->Start(&request, &callback); 1813 int rv = trans->Start(NULL, &request, &callback);
1813 EXPECT_EQ(ERR_IO_PENDING, rv); 1814 EXPECT_EQ(ERR_IO_PENDING, rv);
1814 1815
1815 rv = callback.WaitForResult(); 1816 rv = callback.WaitForResult();
1816 EXPECT_EQ(ERR_RESPONSE_HEADERS_TOO_BIG, rv); 1817 EXPECT_EQ(ERR_RESPONSE_HEADERS_TOO_BIG, rv);
1817 1818
1818 const HttpResponseInfo* response = trans->GetResponseInfo(); 1819 const HttpResponseInfo* response = trans->GetResponseInfo();
1819 EXPECT_TRUE(response == NULL); 1820 EXPECT_TRUE(response == NULL);
1820 } 1821 }
1821 1822
1822 // Make sure that we don't try to reuse a TCPClientSocket when failing to 1823 // Make sure that we don't try to reuse a TCPClientSocket when failing to
(...skipping 27 matching lines...) Expand all
1850 MockRead("HTTP/1.1 404 Not Found\r\n"), 1851 MockRead("HTTP/1.1 404 Not Found\r\n"),
1851 MockRead("Content-Length: 10\r\n\r\n"), 1852 MockRead("Content-Length: 10\r\n\r\n"),
1852 MockRead(false, ERR_UNEXPECTED), // Should not be reached. 1853 MockRead(false, ERR_UNEXPECTED), // Should not be reached.
1853 }; 1854 };
1854 1855
1855 StaticMockSocket data1(data_reads1, data_writes1); 1856 StaticMockSocket data1(data_reads1, data_writes1);
1856 session_deps.socket_factory.AddMockSocket(&data1); 1857 session_deps.socket_factory.AddMockSocket(&data1);
1857 1858
1858 TestCompletionCallback callback1; 1859 TestCompletionCallback callback1;
1859 1860
1860 int rv = trans->Start(&request, &callback1); 1861 int rv = trans->Start(NULL, &request, &callback1);
1861 EXPECT_EQ(ERR_IO_PENDING, rv); 1862 EXPECT_EQ(ERR_IO_PENDING, rv);
1862 1863
1863 rv = callback1.WaitForResult(); 1864 rv = callback1.WaitForResult();
1864 EXPECT_EQ(ERR_TUNNEL_CONNECTION_FAILED, rv); 1865 EXPECT_EQ(ERR_TUNNEL_CONNECTION_FAILED, rv);
1865 1866
1866 const HttpResponseInfo* response = trans->GetResponseInfo(); 1867 const HttpResponseInfo* response = trans->GetResponseInfo();
1867 EXPECT_TRUE(response == NULL); 1868 EXPECT_TRUE(response == NULL);
1868 1869
1869 // Empty the current queue. This is necessary because idle sockets are 1870 // Empty the current queue. This is necessary because idle sockets are
1870 // added to the connection pool asynchronously with a PostTask. 1871 // added to the connection pool asynchronously with a PostTask.
(...skipping 29 matching lines...) Expand all
1900 MockRead(" world"), 1901 MockRead(" world"),
1901 MockRead("junk"), // Should not be read!! 1902 MockRead("junk"), // Should not be read!!
1902 MockRead(false, OK), 1903 MockRead(false, OK),
1903 }; 1904 };
1904 1905
1905 StaticMockSocket data(data_reads, NULL); 1906 StaticMockSocket data(data_reads, NULL);
1906 session_deps.socket_factory.AddMockSocket(&data); 1907 session_deps.socket_factory.AddMockSocket(&data);
1907 1908
1908 TestCompletionCallback callback; 1909 TestCompletionCallback callback;
1909 1910
1910 int rv = trans->Start(&request, &callback); 1911 int rv = trans->Start(NULL, &request, &callback);
1911 EXPECT_EQ(ERR_IO_PENDING, rv); 1912 EXPECT_EQ(ERR_IO_PENDING, rv);
1912 1913
1913 rv = callback.WaitForResult(); 1914 rv = callback.WaitForResult();
1914 EXPECT_EQ(OK, rv); 1915 EXPECT_EQ(OK, rv);
1915 1916
1916 const HttpResponseInfo* response = trans->GetResponseInfo(); 1917 const HttpResponseInfo* response = trans->GetResponseInfo();
1917 EXPECT_TRUE(response != NULL); 1918 EXPECT_TRUE(response != NULL);
1918 1919
1919 EXPECT_TRUE(response->headers != NULL); 1920 EXPECT_TRUE(response->headers != NULL);
1920 std::string status_line = response->headers->GetStatusLine(); 1921 std::string status_line = response->headers->GetStatusLine();
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
1958 "Content-Type: text/html\r\n\r\n"), 1959 "Content-Type: text/html\r\n\r\n"),
1959 MockRead("junk"), // Should not be read!! 1960 MockRead("junk"), // Should not be read!!
1960 MockRead(false, OK), 1961 MockRead(false, OK),
1961 }; 1962 };
1962 1963
1963 StaticMockSocket data(data_reads, NULL); 1964 StaticMockSocket data(data_reads, NULL);
1964 session_deps.socket_factory.AddMockSocket(&data); 1965 session_deps.socket_factory.AddMockSocket(&data);
1965 1966
1966 TestCompletionCallback callback; 1967 TestCompletionCallback callback;
1967 1968
1968 int rv = trans->Start(&request, &callback); 1969 int rv = trans->Start(NULL, &request, &callback);
1969 EXPECT_EQ(ERR_IO_PENDING, rv); 1970 EXPECT_EQ(ERR_IO_PENDING, rv);
1970 1971
1971 rv = callback.WaitForResult(); 1972 rv = callback.WaitForResult();
1972 EXPECT_EQ(OK, rv); 1973 EXPECT_EQ(OK, rv);
1973 1974
1974 const HttpResponseInfo* response = trans->GetResponseInfo(); 1975 const HttpResponseInfo* response = trans->GetResponseInfo();
1975 EXPECT_TRUE(response != NULL); 1976 EXPECT_TRUE(response != NULL);
1976 1977
1977 EXPECT_TRUE(response->headers != NULL); 1978 EXPECT_TRUE(response->headers != NULL);
1978 std::string status_line = response->headers->GetStatusLine(); 1979 std::string status_line = response->headers->GetStatusLine();
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
2052 const char* kExpectedResponseData[] = { 2053 const char* kExpectedResponseData[] = {
2053 "hello world", "welcome" 2054 "hello world", "welcome"
2054 }; 2055 };
2055 2056
2056 for (int i = 0; i < 2; ++i) { 2057 for (int i = 0; i < 2; ++i) {
2057 scoped_ptr<HttpTransaction> trans( 2058 scoped_ptr<HttpTransaction> trans(
2058 new HttpNetworkTransaction(session, &session_deps.socket_factory)); 2059 new HttpNetworkTransaction(session, &session_deps.socket_factory));
2059 2060
2060 TestCompletionCallback callback; 2061 TestCompletionCallback callback;
2061 2062
2062 int rv = trans->Start(&request[i], &callback); 2063 int rv = trans->Start(NULL, &request[i], &callback);
2063 EXPECT_EQ(ERR_IO_PENDING, rv); 2064 EXPECT_EQ(ERR_IO_PENDING, rv);
2064 2065
2065 rv = callback.WaitForResult(); 2066 rv = callback.WaitForResult();
2066 EXPECT_EQ(OK, rv); 2067 EXPECT_EQ(OK, rv);
2067 2068
2068 const HttpResponseInfo* response = trans->GetResponseInfo(); 2069 const HttpResponseInfo* response = trans->GetResponseInfo();
2069 EXPECT_TRUE(response != NULL); 2070 EXPECT_TRUE(response != NULL);
2070 2071
2071 EXPECT_TRUE(response->headers != NULL); 2072 EXPECT_TRUE(response->headers != NULL);
2072 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); 2073 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine());
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
2122 MockRead(false, OK), 2123 MockRead(false, OK),
2123 }; 2124 };
2124 2125
2125 StaticMockSocket data1(data_reads1, data_writes1); 2126 StaticMockSocket data1(data_reads1, data_writes1);
2126 StaticMockSocket data2(data_reads2, data_writes2); 2127 StaticMockSocket data2(data_reads2, data_writes2);
2127 session_deps.socket_factory.AddMockSocket(&data1); 2128 session_deps.socket_factory.AddMockSocket(&data1);
2128 session_deps.socket_factory.AddMockSocket(&data2); 2129 session_deps.socket_factory.AddMockSocket(&data2);
2129 2130
2130 TestCompletionCallback callback1; 2131 TestCompletionCallback callback1;
2131 2132
2132 int rv = trans->Start(&request, &callback1); 2133 int rv = trans->Start(NULL, &request, &callback1);
2133 EXPECT_EQ(ERR_IO_PENDING, rv); 2134 EXPECT_EQ(ERR_IO_PENDING, rv);
2134 2135
2135 rv = callback1.WaitForResult(); 2136 rv = callback1.WaitForResult();
2136 EXPECT_EQ(OK, rv); 2137 EXPECT_EQ(OK, rv);
2137 2138
2138 EXPECT_TRUE(trans->IsReadyToRestartForAuth()); 2139 EXPECT_TRUE(trans->IsReadyToRestartForAuth());
2139 TestCompletionCallback callback2; 2140 TestCompletionCallback callback2;
2140 rv = trans->RestartWithAuth(std::wstring(), std::wstring(), &callback2); 2141 rv = trans->RestartWithAuth(std::wstring(), std::wstring(), &callback2);
2141 EXPECT_EQ(ERR_IO_PENDING, rv); 2142 EXPECT_EQ(ERR_IO_PENDING, rv);
2142 rv = callback2.WaitForResult(); 2143 rv = callback2.WaitForResult();
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
2198 MockRead(false, OK), 2199 MockRead(false, OK),
2199 }; 2200 };
2200 2201
2201 StaticMockSocket data1(data_reads1, data_writes1); 2202 StaticMockSocket data1(data_reads1, data_writes1);
2202 StaticMockSocket data2(data_reads2, data_writes2); 2203 StaticMockSocket data2(data_reads2, data_writes2);
2203 session_deps.socket_factory.AddMockSocket(&data1); 2204 session_deps.socket_factory.AddMockSocket(&data1);
2204 session_deps.socket_factory.AddMockSocket(&data2); 2205 session_deps.socket_factory.AddMockSocket(&data2);
2205 2206
2206 TestCompletionCallback callback1; 2207 TestCompletionCallback callback1;
2207 2208
2208 int rv = trans->Start(&request, &callback1); 2209 int rv = trans->Start(NULL, &request, &callback1);
2209 EXPECT_EQ(ERR_IO_PENDING, rv); 2210 EXPECT_EQ(ERR_IO_PENDING, rv);
2210 2211
2211 rv = callback1.WaitForResult(); 2212 rv = callback1.WaitForResult();
2212 EXPECT_EQ(OK, rv); 2213 EXPECT_EQ(OK, rv);
2213 2214
2214 const HttpResponseInfo* response = trans->GetResponseInfo(); 2215 const HttpResponseInfo* response = trans->GetResponseInfo();
2215 EXPECT_FALSE(response == NULL); 2216 EXPECT_FALSE(response == NULL);
2216 2217
2217 // The password prompt info should have been set in 2218 // The password prompt info should have been set in
2218 // response->auth_challenge. 2219 // response->auth_challenge.
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
2282 MockRead(false, OK), 2283 MockRead(false, OK),
2283 }; 2284 };
2284 2285
2285 StaticMockSocket data1(data_reads1, data_writes1); 2286 StaticMockSocket data1(data_reads1, data_writes1);
2286 StaticMockSocket data2(data_reads2, data_writes2); 2287 StaticMockSocket data2(data_reads2, data_writes2);
2287 session_deps.socket_factory.AddMockSocket(&data1); 2288 session_deps.socket_factory.AddMockSocket(&data1);
2288 session_deps.socket_factory.AddMockSocket(&data2); 2289 session_deps.socket_factory.AddMockSocket(&data2);
2289 2290
2290 TestCompletionCallback callback1; 2291 TestCompletionCallback callback1;
2291 2292
2292 int rv = trans->Start(&request, &callback1); 2293 int rv = trans->Start(NULL, &request, &callback1);
2293 EXPECT_EQ(ERR_IO_PENDING, rv); 2294 EXPECT_EQ(ERR_IO_PENDING, rv);
2294 2295
2295 rv = callback1.WaitForResult(); 2296 rv = callback1.WaitForResult();
2296 EXPECT_EQ(OK, rv); 2297 EXPECT_EQ(OK, rv);
2297 2298
2298 const HttpResponseInfo* response = trans->GetResponseInfo(); 2299 const HttpResponseInfo* response = trans->GetResponseInfo();
2299 EXPECT_FALSE(response == NULL); 2300 EXPECT_FALSE(response == NULL);
2300 2301
2301 // The password prompt info should have been set in 2302 // The password prompt info should have been set in
2302 // response->auth_challenge. 2303 // response->auth_challenge.
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
2347 MockRead("HTTP/1.0 200 OK\r\n"), 2348 MockRead("HTTP/1.0 200 OK\r\n"),
2348 MockRead("Content-Length: 100\r\n\r\n"), 2349 MockRead("Content-Length: 100\r\n\r\n"),
2349 MockRead(false, OK), 2350 MockRead(false, OK),
2350 }; 2351 };
2351 2352
2352 StaticMockSocket data1(data_reads1, data_writes1); 2353 StaticMockSocket data1(data_reads1, data_writes1);
2353 session_deps.socket_factory.AddMockSocket(&data1); 2354 session_deps.socket_factory.AddMockSocket(&data1);
2354 2355
2355 TestCompletionCallback callback1; 2356 TestCompletionCallback callback1;
2356 2357
2357 int rv = trans->Start(&request, &callback1); 2358 int rv = trans->Start(NULL, &request, &callback1);
2358 EXPECT_EQ(ERR_IO_PENDING, rv); 2359 EXPECT_EQ(ERR_IO_PENDING, rv);
2359 2360
2360 rv = callback1.WaitForResult(); 2361 rv = callback1.WaitForResult();
2361 EXPECT_EQ(OK, rv); 2362 EXPECT_EQ(OK, rv);
2362 2363
2363 const HttpResponseInfo* response = trans->GetResponseInfo(); 2364 const HttpResponseInfo* response = trans->GetResponseInfo();
2364 EXPECT_FALSE(response == NULL); 2365 EXPECT_FALSE(response == NULL);
2365 2366
2366 EXPECT_TRUE(response->auth_challenge.get() == NULL); 2367 EXPECT_TRUE(response->auth_challenge.get() == NULL);
2367 EXPECT_EQ(100, response->headers->GetContentLength()); 2368 EXPECT_EQ(100, response->headers->GetContentLength());
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
2408 MockRead(false, OK), 2409 MockRead(false, OK),
2409 }; 2410 };
2410 2411
2411 StaticMockSocket data1(data_reads1, data_writes1); 2412 StaticMockSocket data1(data_reads1, data_writes1);
2412 StaticMockSocket data2(data_reads2, data_writes2); 2413 StaticMockSocket data2(data_reads2, data_writes2);
2413 session_deps.socket_factory.AddMockSocket(&data1); 2414 session_deps.socket_factory.AddMockSocket(&data1);
2414 session_deps.socket_factory.AddMockSocket(&data2); 2415 session_deps.socket_factory.AddMockSocket(&data2);
2415 2416
2416 TestCompletionCallback callback1; 2417 TestCompletionCallback callback1;
2417 2418
2418 int rv = trans->Start(&request, &callback1); 2419 int rv = trans->Start(NULL, &request, &callback1);
2419 EXPECT_EQ(ERR_IO_PENDING, rv); 2420 EXPECT_EQ(ERR_IO_PENDING, rv);
2420 2421
2421 rv = callback1.WaitForResult(); 2422 rv = callback1.WaitForResult();
2422 EXPECT_EQ(OK, rv); 2423 EXPECT_EQ(OK, rv);
2423 2424
2424 EXPECT_TRUE(trans->IsReadyToRestartForAuth()); 2425 EXPECT_TRUE(trans->IsReadyToRestartForAuth());
2425 TestCompletionCallback callback2; 2426 TestCompletionCallback callback2;
2426 rv = trans->RestartWithAuth(std::wstring(), std::wstring(), &callback2); 2427 rv = trans->RestartWithAuth(std::wstring(), std::wstring(), &callback2);
2427 EXPECT_EQ(ERR_IO_PENDING, rv); 2428 EXPECT_EQ(ERR_IO_PENDING, rv);
2428 rv = callback2.WaitForResult(); 2429 rv = callback2.WaitForResult();
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
2495 2496
2496 StaticMockSocket data1(data_reads1, data_writes1); 2497 StaticMockSocket data1(data_reads1, data_writes1);
2497 StaticMockSocket data2(data_reads2, data_writes2); 2498 StaticMockSocket data2(data_reads2, data_writes2);
2498 StaticMockSocket data3(data_reads3, data_writes3); 2499 StaticMockSocket data3(data_reads3, data_writes3);
2499 session_deps.socket_factory.AddMockSocket(&data1); 2500 session_deps.socket_factory.AddMockSocket(&data1);
2500 session_deps.socket_factory.AddMockSocket(&data2); 2501 session_deps.socket_factory.AddMockSocket(&data2);
2501 session_deps.socket_factory.AddMockSocket(&data3); 2502 session_deps.socket_factory.AddMockSocket(&data3);
2502 2503
2503 TestCompletionCallback callback1; 2504 TestCompletionCallback callback1;
2504 2505
2505 int rv = trans->Start(&request, &callback1); 2506 int rv = trans->Start(NULL, &request, &callback1);
2506 EXPECT_EQ(ERR_IO_PENDING, rv); 2507 EXPECT_EQ(ERR_IO_PENDING, rv);
2507 2508
2508 rv = callback1.WaitForResult(); 2509 rv = callback1.WaitForResult();
2509 EXPECT_EQ(OK, rv); 2510 EXPECT_EQ(OK, rv);
2510 2511
2511 EXPECT_TRUE(trans->IsReadyToRestartForAuth()); 2512 EXPECT_TRUE(trans->IsReadyToRestartForAuth());
2512 TestCompletionCallback callback2; 2513 TestCompletionCallback callback2;
2513 rv = trans->RestartWithAuth(std::wstring(), std::wstring(), &callback2); 2514 rv = trans->RestartWithAuth(std::wstring(), std::wstring(), &callback2);
2514 EXPECT_EQ(ERR_IO_PENDING, rv); 2515 EXPECT_EQ(ERR_IO_PENDING, rv);
2515 rv = callback2.WaitForResult(); 2516 rv = callback2.WaitForResult();
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
2632 MockSSLSocket ssl_bad(true, ERR_CERT_AUTHORITY_INVALID); 2633 MockSSLSocket ssl_bad(true, ERR_CERT_AUTHORITY_INVALID);
2633 MockSSLSocket ssl(true, OK); 2634 MockSSLSocket ssl(true, OK);
2634 2635
2635 session_deps.socket_factory.AddMockSocket(&ssl_bad_certificate); 2636 session_deps.socket_factory.AddMockSocket(&ssl_bad_certificate);
2636 session_deps.socket_factory.AddMockSocket(&data); 2637 session_deps.socket_factory.AddMockSocket(&data);
2637 session_deps.socket_factory.AddMockSSLSocket(&ssl_bad); 2638 session_deps.socket_factory.AddMockSSLSocket(&ssl_bad);
2638 session_deps.socket_factory.AddMockSSLSocket(&ssl); 2639 session_deps.socket_factory.AddMockSSLSocket(&ssl);
2639 2640
2640 TestCompletionCallback callback; 2641 TestCompletionCallback callback;
2641 2642
2642 int rv = trans->Start(&request, &callback); 2643 int rv = trans->Start(NULL, &request, &callback);
2643 EXPECT_EQ(ERR_IO_PENDING, rv); 2644 EXPECT_EQ(ERR_IO_PENDING, rv);
2644 2645
2645 rv = callback.WaitForResult(); 2646 rv = callback.WaitForResult();
2646 EXPECT_EQ(ERR_CERT_AUTHORITY_INVALID, rv); 2647 EXPECT_EQ(ERR_CERT_AUTHORITY_INVALID, rv);
2647 2648
2648 rv = trans->RestartIgnoringLastError(&callback); 2649 rv = trans->RestartIgnoringLastError(&callback);
2649 EXPECT_EQ(ERR_IO_PENDING, rv); 2650 EXPECT_EQ(ERR_IO_PENDING, rv);
2650 2651
2651 rv = callback.WaitForResult(); 2652 rv = callback.WaitForResult();
2652 EXPECT_EQ(OK, rv); 2653 EXPECT_EQ(OK, rv);
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
2708 TestCompletionCallback callback; 2709 TestCompletionCallback callback;
2709 2710
2710 for (int i = 0; i < 2; i++) { 2711 for (int i = 0; i < 2; i++) {
2711 session_deps.socket_factory.ResetNextMockIndexes(); 2712 session_deps.socket_factory.ResetNextMockIndexes();
2712 2713
2713 scoped_ptr<HttpTransaction> trans( 2714 scoped_ptr<HttpTransaction> trans(
2714 new HttpNetworkTransaction( 2715 new HttpNetworkTransaction(
2715 CreateSession(&session_deps), 2716 CreateSession(&session_deps),
2716 &session_deps.socket_factory)); 2717 &session_deps.socket_factory));
2717 2718
2718 int rv = trans->Start(&request, &callback); 2719 int rv = trans->Start(NULL, &request, &callback);
2719 EXPECT_EQ(ERR_IO_PENDING, rv); 2720 EXPECT_EQ(ERR_IO_PENDING, rv);
2720 2721
2721 rv = callback.WaitForResult(); 2722 rv = callback.WaitForResult();
2722 EXPECT_EQ(ERR_CERT_AUTHORITY_INVALID, rv); 2723 EXPECT_EQ(ERR_CERT_AUTHORITY_INVALID, rv);
2723 2724
2724 rv = trans->RestartIgnoringLastError(&callback); 2725 rv = trans->RestartIgnoringLastError(&callback);
2725 EXPECT_EQ(ERR_IO_PENDING, rv); 2726 EXPECT_EQ(ERR_IO_PENDING, rv);
2726 2727
2727 rv = callback.WaitForResult(); 2728 rv = callback.WaitForResult();
2728 EXPECT_EQ(OK, rv); 2729 EXPECT_EQ(OK, rv);
(...skipping 30 matching lines...) Expand all
2759 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n"), 2760 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n"),
2760 MockRead("Content-Length: 100\r\n\r\n"), 2761 MockRead("Content-Length: 100\r\n\r\n"),
2761 MockRead(false, OK), 2762 MockRead(false, OK),
2762 }; 2763 };
2763 2764
2764 StaticMockSocket data(data_reads, data_writes); 2765 StaticMockSocket data(data_reads, data_writes);
2765 session_deps.socket_factory.AddMockSocket(&data); 2766 session_deps.socket_factory.AddMockSocket(&data);
2766 2767
2767 TestCompletionCallback callback; 2768 TestCompletionCallback callback;
2768 2769
2769 int rv = trans->Start(&request, &callback); 2770 int rv = trans->Start(NULL, &request, &callback);
2770 EXPECT_EQ(ERR_IO_PENDING, rv); 2771 EXPECT_EQ(ERR_IO_PENDING, rv);
2771 2772
2772 rv = callback.WaitForResult(); 2773 rv = callback.WaitForResult();
2773 EXPECT_EQ(OK, rv); 2774 EXPECT_EQ(OK, rv);
2774 } 2775 }
2775 2776
2776 TEST_F(HttpNetworkTransactionTest, BuildRequest_Referer) { 2777 TEST_F(HttpNetworkTransactionTest, BuildRequest_Referer) {
2777 SessionDependencies session_deps; 2778 SessionDependencies session_deps;
2778 scoped_ptr<HttpTransaction> trans( 2779 scoped_ptr<HttpTransaction> trans(
2779 new HttpNetworkTransaction( 2780 new HttpNetworkTransaction(
(...skipping 19 matching lines...) Expand all
2799 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n"), 2800 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n"),
2800 MockRead("Content-Length: 100\r\n\r\n"), 2801 MockRead("Content-Length: 100\r\n\r\n"),
2801 MockRead(false, OK), 2802 MockRead(false, OK),
2802 }; 2803 };
2803 2804
2804 StaticMockSocket data(data_reads, data_writes); 2805 StaticMockSocket data(data_reads, data_writes);
2805 session_deps.socket_factory.AddMockSocket(&data); 2806 session_deps.socket_factory.AddMockSocket(&data);
2806 2807
2807 TestCompletionCallback callback; 2808 TestCompletionCallback callback;
2808 2809
2809 int rv = trans->Start(&request, &callback); 2810 int rv = trans->Start(NULL, &request, &callback);
2810 EXPECT_EQ(ERR_IO_PENDING, rv); 2811 EXPECT_EQ(ERR_IO_PENDING, rv);
2811 2812
2812 rv = callback.WaitForResult(); 2813 rv = callback.WaitForResult();
2813 EXPECT_EQ(OK, rv); 2814 EXPECT_EQ(OK, rv);
2814 } 2815 }
2815 2816
2816 TEST_F(HttpNetworkTransactionTest, BuildRequest_PostContentLengthZero) { 2817 TEST_F(HttpNetworkTransactionTest, BuildRequest_PostContentLengthZero) {
2817 SessionDependencies session_deps; 2818 SessionDependencies session_deps;
2818 scoped_ptr<HttpTransaction> trans( 2819 scoped_ptr<HttpTransaction> trans(
2819 new HttpNetworkTransaction( 2820 new HttpNetworkTransaction(
(...skipping 17 matching lines...) Expand all
2837 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n"), 2838 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n"),
2838 MockRead("Content-Length: 100\r\n\r\n"), 2839 MockRead("Content-Length: 100\r\n\r\n"),
2839 MockRead(false, OK), 2840 MockRead(false, OK),
2840 }; 2841 };
2841 2842
2842 StaticMockSocket data(data_reads, data_writes); 2843 StaticMockSocket data(data_reads, data_writes);
2843 session_deps.socket_factory.AddMockSocket(&data); 2844 session_deps.socket_factory.AddMockSocket(&data);
2844 2845
2845 TestCompletionCallback callback; 2846 TestCompletionCallback callback;
2846 2847
2847 int rv = trans->Start(&request, &callback); 2848 int rv = trans->Start(NULL, &request, &callback);
2848 EXPECT_EQ(ERR_IO_PENDING, rv); 2849 EXPECT_EQ(ERR_IO_PENDING, rv);
2849 2850
2850 rv = callback.WaitForResult(); 2851 rv = callback.WaitForResult();
2851 EXPECT_EQ(OK, rv); 2852 EXPECT_EQ(OK, rv);
2852 } 2853 }
2853 2854
2854 TEST_F(HttpNetworkTransactionTest, BuildRequest_PutContentLengthZero) { 2855 TEST_F(HttpNetworkTransactionTest, BuildRequest_PutContentLengthZero) {
2855 SessionDependencies session_deps; 2856 SessionDependencies session_deps;
2856 scoped_ptr<HttpTransaction> trans( 2857 scoped_ptr<HttpTransaction> trans(
2857 new HttpNetworkTransaction( 2858 new HttpNetworkTransaction(
(...skipping 17 matching lines...) Expand all
2875 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n"), 2876 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n"),
2876 MockRead("Content-Length: 100\r\n\r\n"), 2877 MockRead("Content-Length: 100\r\n\r\n"),
2877 MockRead(false, OK), 2878 MockRead(false, OK),
2878 }; 2879 };
2879 2880
2880 StaticMockSocket data(data_reads, data_writes); 2881 StaticMockSocket data(data_reads, data_writes);
2881 session_deps.socket_factory.AddMockSocket(&data); 2882 session_deps.socket_factory.AddMockSocket(&data);
2882 2883
2883 TestCompletionCallback callback; 2884 TestCompletionCallback callback;
2884 2885
2885 int rv = trans->Start(&request, &callback); 2886 int rv = trans->Start(NULL, &request, &callback);
2886 EXPECT_EQ(ERR_IO_PENDING, rv); 2887 EXPECT_EQ(ERR_IO_PENDING, rv);
2887 2888
2888 rv = callback.WaitForResult(); 2889 rv = callback.WaitForResult();
2889 EXPECT_EQ(OK, rv); 2890 EXPECT_EQ(OK, rv);
2890 } 2891 }
2891 2892
2892 TEST_F(HttpNetworkTransactionTest, BuildRequest_HeadContentLengthZero) { 2893 TEST_F(HttpNetworkTransactionTest, BuildRequest_HeadContentLengthZero) {
2893 SessionDependencies session_deps; 2894 SessionDependencies session_deps;
2894 scoped_ptr<HttpTransaction> trans( 2895 scoped_ptr<HttpTransaction> trans(
2895 new HttpNetworkTransaction( 2896 new HttpNetworkTransaction(
(...skipping 17 matching lines...) Expand all
2913 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n"), 2914 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n"),
2914 MockRead("Content-Length: 100\r\n\r\n"), 2915 MockRead("Content-Length: 100\r\n\r\n"),
2915 MockRead(false, OK), 2916 MockRead(false, OK),
2916 }; 2917 };
2917 2918
2918 StaticMockSocket data(data_reads, data_writes); 2919 StaticMockSocket data(data_reads, data_writes);
2919 session_deps.socket_factory.AddMockSocket(&data); 2920 session_deps.socket_factory.AddMockSocket(&data);
2920 2921
2921 TestCompletionCallback callback; 2922 TestCompletionCallback callback;
2922 2923
2923 int rv = trans->Start(&request, &callback); 2924 int rv = trans->Start(NULL, &request, &callback);
2924 EXPECT_EQ(ERR_IO_PENDING, rv); 2925 EXPECT_EQ(ERR_IO_PENDING, rv);
2925 2926
2926 rv = callback.WaitForResult(); 2927 rv = callback.WaitForResult();
2927 EXPECT_EQ(OK, rv); 2928 EXPECT_EQ(OK, rv);
2928 } 2929 }
2929 2930
2930 TEST_F(HttpNetworkTransactionTest, BuildRequest_CacheControlNoCache) { 2931 TEST_F(HttpNetworkTransactionTest, BuildRequest_CacheControlNoCache) {
2931 SessionDependencies session_deps; 2932 SessionDependencies session_deps;
2932 scoped_ptr<HttpTransaction> trans( 2933 scoped_ptr<HttpTransaction> trans(
2933 new HttpNetworkTransaction( 2934 new HttpNetworkTransaction(
(...skipping 19 matching lines...) Expand all
2953 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n"), 2954 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n"),
2954 MockRead("Content-Length: 100\r\n\r\n"), 2955 MockRead("Content-Length: 100\r\n\r\n"),
2955 MockRead(false, OK), 2956 MockRead(false, OK),
2956 }; 2957 };
2957 2958
2958 StaticMockSocket data(data_reads, data_writes); 2959 StaticMockSocket data(data_reads, data_writes);
2959 session_deps.socket_factory.AddMockSocket(&data); 2960 session_deps.socket_factory.AddMockSocket(&data);
2960 2961
2961 TestCompletionCallback callback; 2962 TestCompletionCallback callback;
2962 2963
2963 int rv = trans->Start(&request, &callback); 2964 int rv = trans->Start(NULL, &request, &callback);
2964 EXPECT_EQ(ERR_IO_PENDING, rv); 2965 EXPECT_EQ(ERR_IO_PENDING, rv);
2965 2966
2966 rv = callback.WaitForResult(); 2967 rv = callback.WaitForResult();
2967 EXPECT_EQ(OK, rv); 2968 EXPECT_EQ(OK, rv);
2968 } 2969 }
2969 2970
2970 TEST_F(HttpNetworkTransactionTest, 2971 TEST_F(HttpNetworkTransactionTest,
2971 BuildRequest_CacheControlValidateCache) { 2972 BuildRequest_CacheControlValidateCache) {
2972 SessionDependencies session_deps; 2973 SessionDependencies session_deps;
2973 scoped_ptr<HttpTransaction> trans( 2974 scoped_ptr<HttpTransaction> trans(
(...skipping 19 matching lines...) Expand all
2993 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n"), 2994 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n"),
2994 MockRead("Content-Length: 100\r\n\r\n"), 2995 MockRead("Content-Length: 100\r\n\r\n"),
2995 MockRead(false, OK), 2996 MockRead(false, OK),
2996 }; 2997 };
2997 2998
2998 StaticMockSocket data(data_reads, data_writes); 2999 StaticMockSocket data(data_reads, data_writes);
2999 session_deps.socket_factory.AddMockSocket(&data); 3000 session_deps.socket_factory.AddMockSocket(&data);
3000 3001
3001 TestCompletionCallback callback; 3002 TestCompletionCallback callback;
3002 3003
3003 int rv = trans->Start(&request, &callback); 3004 int rv = trans->Start(NULL, &request, &callback);
3004 EXPECT_EQ(ERR_IO_PENDING, rv); 3005 EXPECT_EQ(ERR_IO_PENDING, rv);
3005 3006
3006 rv = callback.WaitForResult(); 3007 rv = callback.WaitForResult();
3007 EXPECT_EQ(OK, rv); 3008 EXPECT_EQ(OK, rv);
3008 } 3009 }
3009 3010
3010 TEST_F(HttpNetworkTransactionTest, BuildRequest_ExtraHeaders) { 3011 TEST_F(HttpNetworkTransactionTest, BuildRequest_ExtraHeaders) {
3011 SessionDependencies session_deps; 3012 SessionDependencies session_deps;
3012 scoped_ptr<HttpTransaction> trans( 3013 scoped_ptr<HttpTransaction> trans(
3013 new HttpNetworkTransaction( 3014 new HttpNetworkTransaction(
(...skipping 18 matching lines...) Expand all
3032 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n"), 3033 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n"),
3033 MockRead("Content-Length: 100\r\n\r\n"), 3034 MockRead("Content-Length: 100\r\n\r\n"),
3034 MockRead(false, OK), 3035 MockRead(false, OK),
3035 }; 3036 };
3036 3037
3037 StaticMockSocket data(data_reads, data_writes); 3038 StaticMockSocket data(data_reads, data_writes);
3038 session_deps.socket_factory.AddMockSocket(&data); 3039 session_deps.socket_factory.AddMockSocket(&data);
3039 3040
3040 TestCompletionCallback callback; 3041 TestCompletionCallback callback;
3041 3042
3042 int rv = trans->Start(&request, &callback); 3043 int rv = trans->Start(NULL, &request, &callback);
3043 EXPECT_EQ(ERR_IO_PENDING, rv); 3044 EXPECT_EQ(ERR_IO_PENDING, rv);
3044 3045
3045 rv = callback.WaitForResult(); 3046 rv = callback.WaitForResult();
3046 EXPECT_EQ(OK, rv); 3047 EXPECT_EQ(OK, rv);
3047 } 3048 }
3048 3049
3049 TEST_F(HttpNetworkTransactionTest, SOCKS4_HTTP_GET) { 3050 TEST_F(HttpNetworkTransactionTest, SOCKS4_HTTP_GET) {
3050 SessionDependencies session_deps; 3051 SessionDependencies session_deps;
3051 session_deps.proxy_service.reset(CreateFixedProxyService( 3052 session_deps.proxy_service.reset(CreateFixedProxyService(
3052 "socks4://myproxy:1080")); 3053 "socks4://myproxy:1080"));
(...skipping 24 matching lines...) Expand all
3077 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n\r\n"), 3078 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n\r\n"),
3078 MockRead("Payload"), 3079 MockRead("Payload"),
3079 MockRead(false, OK) 3080 MockRead(false, OK)
3080 }; 3081 };
3081 3082
3082 StaticMockSocket data(data_reads, data_writes); 3083 StaticMockSocket data(data_reads, data_writes);
3083 session_deps.socket_factory.AddMockSocket(&data); 3084 session_deps.socket_factory.AddMockSocket(&data);
3084 3085
3085 TestCompletionCallback callback; 3086 TestCompletionCallback callback;
3086 3087
3087 int rv = trans->Start(&request, &callback); 3088 int rv = trans->Start(NULL, &request, &callback);
3088 EXPECT_EQ(ERR_IO_PENDING, rv); 3089 EXPECT_EQ(ERR_IO_PENDING, rv);
3089 3090
3090 rv = callback.WaitForResult(); 3091 rv = callback.WaitForResult();
3091 EXPECT_EQ(OK, rv); 3092 EXPECT_EQ(OK, rv);
3092 3093
3093 const HttpResponseInfo* response = trans->GetResponseInfo(); 3094 const HttpResponseInfo* response = trans->GetResponseInfo();
3094 EXPECT_FALSE(response == NULL); 3095 EXPECT_FALSE(response == NULL);
3095 3096
3096 std::string response_text; 3097 std::string response_text;
3097 rv = ReadTransaction(trans.get(), &response_text); 3098 rv = ReadTransaction(trans.get(), &response_text);
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
3135 }; 3136 };
3136 3137
3137 StaticMockSocket data(data_reads, data_writes); 3138 StaticMockSocket data(data_reads, data_writes);
3138 session_deps.socket_factory.AddMockSocket(&data); 3139 session_deps.socket_factory.AddMockSocket(&data);
3139 3140
3140 MockSSLSocket ssl(true, OK); 3141 MockSSLSocket ssl(true, OK);
3141 session_deps.socket_factory.AddMockSSLSocket(&ssl); 3142 session_deps.socket_factory.AddMockSSLSocket(&ssl);
3142 3143
3143 TestCompletionCallback callback; 3144 TestCompletionCallback callback;
3144 3145
3145 int rv = trans->Start(&request, &callback); 3146 int rv = trans->Start(NULL, &request, &callback);
3146 EXPECT_EQ(ERR_IO_PENDING, rv); 3147 EXPECT_EQ(ERR_IO_PENDING, rv);
3147 3148
3148 rv = callback.WaitForResult(); 3149 rv = callback.WaitForResult();
3149 EXPECT_EQ(OK, rv); 3150 EXPECT_EQ(OK, rv);
3150 3151
3151 const HttpResponseInfo* response = trans->GetResponseInfo(); 3152 const HttpResponseInfo* response = trans->GetResponseInfo();
3152 EXPECT_FALSE(response == NULL); 3153 EXPECT_FALSE(response == NULL);
3153 3154
3154 std::string response_text; 3155 std::string response_text;
3155 rv = ReadTransaction(trans.get(), &response_text); 3156 rv = ReadTransaction(trans.get(), &response_text);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
3194 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n\r\n"), 3195 MockRead("Content-Type: text/html; charset=iso-8859-1\r\n\r\n"),
3195 MockRead("Payload"), 3196 MockRead("Payload"),
3196 MockRead(false, OK) 3197 MockRead(false, OK)
3197 }; 3198 };
3198 3199
3199 StaticMockSocket data(data_reads, data_writes); 3200 StaticMockSocket data(data_reads, data_writes);
3200 session_deps.socket_factory.AddMockSocket(&data); 3201 session_deps.socket_factory.AddMockSocket(&data);
3201 3202
3202 TestCompletionCallback callback; 3203 TestCompletionCallback callback;
3203 3204
3204 int rv = trans->Start(&request, &callback); 3205 int rv = trans->Start(NULL, &request, &callback);
3205 EXPECT_EQ(ERR_IO_PENDING, rv); 3206 EXPECT_EQ(ERR_IO_PENDING, rv);
3206 3207
3207 rv = callback.WaitForResult(); 3208 rv = callback.WaitForResult();
3208 EXPECT_EQ(OK, rv); 3209 EXPECT_EQ(OK, rv);
3209 3210
3210 const HttpResponseInfo* response = trans->GetResponseInfo(); 3211 const HttpResponseInfo* response = trans->GetResponseInfo();
3211 EXPECT_FALSE(response == NULL); 3212 EXPECT_FALSE(response == NULL);
3212 3213
3213 std::string response_text; 3214 std::string response_text;
3214 rv = ReadTransaction(trans.get(), &response_text); 3215 rv = ReadTransaction(trans.get(), &response_text);
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
3257 }; 3258 };
3258 3259
3259 StaticMockSocket data(data_reads, data_writes); 3260 StaticMockSocket data(data_reads, data_writes);
3260 session_deps.socket_factory.AddMockSocket(&data); 3261 session_deps.socket_factory.AddMockSocket(&data);
3261 3262
3262 MockSSLSocket ssl(true, OK); 3263 MockSSLSocket ssl(true, OK);
3263 session_deps.socket_factory.AddMockSSLSocket(&ssl); 3264 session_deps.socket_factory.AddMockSSLSocket(&ssl);
3264 3265
3265 TestCompletionCallback callback; 3266 TestCompletionCallback callback;
3266 3267
3267 int rv = trans->Start(&request, &callback); 3268 int rv = trans->Start(NULL, &request, &callback);
3268 EXPECT_EQ(ERR_IO_PENDING, rv); 3269 EXPECT_EQ(ERR_IO_PENDING, rv);
3269 3270
3270 rv = callback.WaitForResult(); 3271 rv = callback.WaitForResult();
3271 EXPECT_EQ(OK, rv); 3272 EXPECT_EQ(OK, rv);
3272 3273
3273 const HttpResponseInfo* response = trans->GetResponseInfo(); 3274 const HttpResponseInfo* response = trans->GetResponseInfo();
3274 EXPECT_FALSE(response == NULL); 3275 EXPECT_FALSE(response == NULL);
3275 3276
3276 std::string response_text; 3277 std::string response_text;
3277 rv = ReadTransaction(trans.get(), &response_text); 3278 rv = ReadTransaction(trans.get(), &response_text);
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
3337 &session_deps.socket_factory)); 3338 &session_deps.socket_factory));
3338 3339
3339 HttpRequestInfo request; 3340 HttpRequestInfo request;
3340 request.method = "GET"; 3341 request.method = "GET";
3341 request.url = GURL(tests[i].url); 3342 request.url = GURL(tests[i].url);
3342 request.load_flags = 0; 3343 request.load_flags = 0;
3343 3344
3344 TestCompletionCallback callback; 3345 TestCompletionCallback callback;
3345 3346
3346 // We do not complete this request, the dtor will clean the transaction up. 3347 // We do not complete this request, the dtor will clean the transaction up.
3347 EXPECT_EQ(ERR_IO_PENDING, trans->Start(&request, &callback)); 3348 EXPECT_EQ(ERR_IO_PENDING, trans->Start(NULL, &request, &callback));
3348 EXPECT_EQ(tests[i].expected_group_name, 3349 EXPECT_EQ(tests[i].expected_group_name,
3349 conn_pool->last_group_name_received()); 3350 conn_pool->last_group_name_received());
3350 } 3351 }
3351 } 3352 }
3352 3353
3353 TEST_F(HttpNetworkTransactionTest, ReconsiderProxyAfterFailedConnection) { 3354 TEST_F(HttpNetworkTransactionTest, ReconsiderProxyAfterFailedConnection) {
3354 SessionDependencies session_deps( 3355 SessionDependencies session_deps(
3355 CreateFixedProxyService("myproxy:70;foobar:80")); 3356 CreateFixedProxyService("myproxy:70;foobar:80"));
3356 3357
3357 session_deps.host_resolver->rules()->AddSimulatedFailure("*"); 3358 session_deps.host_resolver->rules()->AddSimulatedFailure("*");
3358 3359
3359 scoped_ptr<HttpTransaction> trans( 3360 scoped_ptr<HttpTransaction> trans(
3360 new HttpNetworkTransaction( 3361 new HttpNetworkTransaction(
3361 CreateSession(&session_deps), 3362 CreateSession(&session_deps),
3362 &session_deps.socket_factory)); 3363 &session_deps.socket_factory));
3363 3364
3364 HttpRequestInfo request; 3365 HttpRequestInfo request;
3365 request.method = "GET"; 3366 request.method = "GET";
3366 request.url = GURL("http://www.google.com/"); 3367 request.url = GURL("http://www.google.com/");
3367 3368
3368 TestCompletionCallback callback; 3369 TestCompletionCallback callback;
3369 3370
3370 int rv = trans->Start(&request, &callback); 3371 int rv = trans->Start(NULL, &request, &callback);
3371 EXPECT_EQ(ERR_IO_PENDING, rv); 3372 EXPECT_EQ(ERR_IO_PENDING, rv);
3372 3373
3373 rv = callback.WaitForResult(); 3374 rv = callback.WaitForResult();
3374 EXPECT_EQ(ERR_NAME_NOT_RESOLVED, rv); 3375 EXPECT_EQ(ERR_NAME_NOT_RESOLVED, rv);
3375 } 3376 }
3376 3377
3377 // Host resolution observer used by 3378 // Host resolution observer used by
3378 // HttpNetworkTransactionTest.ResolveMadeWithReferrer to check that host 3379 // HttpNetworkTransactionTest.ResolveMadeWithReferrer to check that host
3379 // resovle requests are issued with a referrer of |expected_referrer|. 3380 // resovle requests are issued with a referrer of |expected_referrer|.
3380 class ResolutionReferrerObserver : public HostResolver::Observer { 3381 class ResolutionReferrerObserver : public HostResolver::Observer {
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
3436 session_deps.socket_factory.AddMockSocket(&data); 3437 session_deps.socket_factory.AddMockSocket(&data);
3437 3438
3438 // Issue a request, containing an HTTP referrer. 3439 // Issue a request, containing an HTTP referrer.
3439 HttpRequestInfo request; 3440 HttpRequestInfo request;
3440 request.method = "GET"; 3441 request.method = "GET";
3441 request.referrer = referrer; 3442 request.referrer = referrer;
3442 request.url = GURL("http://www.google.com/"); 3443 request.url = GURL("http://www.google.com/");
3443 3444
3444 // Run the request until it fails reading from the socket. 3445 // Run the request until it fails reading from the socket.
3445 TestCompletionCallback callback; 3446 TestCompletionCallback callback;
3446 int rv = trans->Start(&request, &callback); 3447 int rv = trans->Start(NULL, &request, &callback);
3447 EXPECT_EQ(ERR_IO_PENDING, rv); 3448 EXPECT_EQ(ERR_IO_PENDING, rv);
3448 rv = callback.WaitForResult(); 3449 rv = callback.WaitForResult();
3449 EXPECT_EQ(ERR_FAILED, rv); 3450 EXPECT_EQ(ERR_FAILED, rv);
3450 3451
3451 // Check that the host resolution observer saw |referrer|. 3452 // Check that the host resolution observer saw |referrer|.
3452 EXPECT_TRUE(resolution_observer.did_complete_with_expected_referrer()); 3453 EXPECT_TRUE(resolution_observer.did_complete_with_expected_referrer());
3453 } 3454 }
3454 3455
3455 // Make sure that when the load flags contain LOAD_BYPASS_CACHE, the resolver's 3456 // Make sure that when the load flags contain LOAD_BYPASS_CACHE, the resolver's
3456 // host cache is bypassed. 3457 // host cache is bypassed.
3457 TEST_F(HttpNetworkTransactionTest, BypassHostCacheOnRefresh) { 3458 TEST_F(HttpNetworkTransactionTest, BypassHostCacheOnRefresh) {
3458 SessionDependencies session_deps; 3459 SessionDependencies session_deps;
3459 3460
3460 // Select a host resolver that does caching. 3461 // Select a host resolver that does caching.
3461 session_deps.host_resolver = new MockCachingHostResolver; 3462 session_deps.host_resolver = new MockCachingHostResolver;
3462 3463
3463 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction( 3464 scoped_ptr<HttpTransaction> trans(new HttpNetworkTransaction(
3464 CreateSession(&session_deps), &session_deps.socket_factory)); 3465 CreateSession(&session_deps), &session_deps.socket_factory));
3465 3466
3466 // Warm up the host cache so it has an entry for "www.google.com" (by doing 3467 // Warm up the host cache so it has an entry for "www.google.com" (by doing
3467 // a synchronous lookup.) 3468 // a synchronous lookup.)
3468 AddressList addrlist; 3469 AddressList addrlist;
3469 int rv = session_deps.host_resolver->Resolve( 3470 int rv = session_deps.host_resolver->Resolve(
3470 HostResolver::RequestInfo("www.google.com", 80), &addrlist, NULL, NULL); 3471 NULL, HostResolver::RequestInfo("www.google.com", 80), &addrlist,
3472 NULL, NULL);
3471 EXPECT_EQ(OK, rv); 3473 EXPECT_EQ(OK, rv);
3472 3474
3473 // Verify that it was added to host cache, by doing a subsequent async lookup 3475 // Verify that it was added to host cache, by doing a subsequent async lookup
3474 // and confirming it completes synchronously. 3476 // and confirming it completes synchronously.
3475 TestCompletionCallback resolve_callback; 3477 TestCompletionCallback resolve_callback;
3476 rv = session_deps.host_resolver->Resolve( 3478 rv = session_deps.host_resolver->Resolve(NULL,
3477 HostResolver::RequestInfo("www.google.com", 80), &addrlist, 3479 HostResolver::RequestInfo("www.google.com", 80), &addrlist,
3478 &resolve_callback, NULL); 3480 &resolve_callback, NULL);
3479 ASSERT_EQ(OK, rv); 3481 ASSERT_EQ(OK, rv);
3480 3482
3481 // Inject a failure the next time that "www.google.com" is resolved. This way 3483 // Inject a failure the next time that "www.google.com" is resolved. This way
3482 // we can tell if the next lookup hit the cache, or the "network". 3484 // we can tell if the next lookup hit the cache, or the "network".
3483 // (cache --> success, "network" --> failure). 3485 // (cache --> success, "network" --> failure).
3484 session_deps.host_resolver->rules()->AddSimulatedFailure("www.google.com"); 3486 session_deps.host_resolver->rules()->AddSimulatedFailure("www.google.com");
3485 3487
3486 // Connect up a mock socket which will fail with ERR_UNEXPECTED during the 3488 // Connect up a mock socket which will fail with ERR_UNEXPECTED during the
3487 // first read -- this won't be reached as the host resolution will fail first. 3489 // first read -- this won't be reached as the host resolution will fail first.
3488 MockRead data_reads[] = { MockRead(false, ERR_UNEXPECTED) }; 3490 MockRead data_reads[] = { MockRead(false, ERR_UNEXPECTED) };
3489 StaticMockSocket data(data_reads, NULL); 3491 StaticMockSocket data(data_reads, NULL);
3490 session_deps.socket_factory.AddMockSocket(&data); 3492 session_deps.socket_factory.AddMockSocket(&data);
3491 3493
3492 // Issue a request, asking to bypass the cache(s). 3494 // Issue a request, asking to bypass the cache(s).
3493 HttpRequestInfo request; 3495 HttpRequestInfo request;
3494 request.method = "GET"; 3496 request.method = "GET";
3495 request.load_flags = LOAD_BYPASS_CACHE; 3497 request.load_flags = LOAD_BYPASS_CACHE;
3496 request.url = GURL("http://www.google.com/"); 3498 request.url = GURL("http://www.google.com/");
3497 3499
3498 // Run the request. 3500 // Run the request.
3499 TestCompletionCallback callback; 3501 TestCompletionCallback callback;
3500 rv = trans->Start(&request, &callback); 3502 rv = trans->Start(NULL, &request, &callback);
3501 ASSERT_EQ(ERR_IO_PENDING, rv); 3503 ASSERT_EQ(ERR_IO_PENDING, rv);
3502 rv = callback.WaitForResult(); 3504 rv = callback.WaitForResult();
3503 3505
3504 // If we bypassed the cache, we would have gotten a failure while resolving 3506 // If we bypassed the cache, we would have gotten a failure while resolving
3505 // "www.google.com". 3507 // "www.google.com".
3506 EXPECT_EQ(ERR_NAME_NOT_RESOLVED, rv); 3508 EXPECT_EQ(ERR_NAME_NOT_RESOLVED, rv);
3507 } 3509 }
3508 3510
3509 } // namespace net 3511 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_network_transaction.cc ('k') | net/http/http_transaction.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698