OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <string> | 5 #include <string> |
6 | 6 |
7 #include "base/memory/ref_counted.h" | 7 #include "base/memory/ref_counted.h" |
8 #include "base/memory/scoped_vector.h" | 8 #include "base/memory/scoped_vector.h" |
9 #include "base/stringprintf.h" | 9 #include "base/stringprintf.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
412 two_transaction.Start(GetRequestInfo("two.html"), &two_callback, | 412 two_transaction.Start(GetRequestInfo("two.html"), &two_callback, |
413 BoundNetLog())); | 413 BoundNetLog())); |
414 | 414 |
415 data_vector_[0]->RunFor(1); | 415 data_vector_[0]->RunFor(1); |
416 EXPECT_EQ(ERR_FAILED, one_callback.WaitForResult()); | 416 EXPECT_EQ(ERR_FAILED, one_callback.WaitForResult()); |
417 | 417 |
418 EXPECT_EQ(OK, two_callback.WaitForResult()); | 418 EXPECT_EQ(OK, two_callback.WaitForResult()); |
419 ExpectResponse("two.html", two_transaction); | 419 ExpectResponse("two.html", two_transaction); |
420 } | 420 } |
421 | 421 |
| 422 TEST_F(HttpPipelinedNetworkTransactionTest, RedirectDrained) { |
| 423 Initialize(); |
| 424 |
| 425 MockWrite writes[] = { |
| 426 MockWrite(false, 0, "GET /redirect.html HTTP/1.1\r\n" |
| 427 "Host: localhost\r\n" |
| 428 "Connection: keep-alive\r\n\r\n"), |
| 429 MockWrite(false, 3, "GET /two.html HTTP/1.1\r\n" |
| 430 "Host: localhost\r\n" |
| 431 "Connection: keep-alive\r\n\r\n"), |
| 432 }; |
| 433 MockRead reads[] = { |
| 434 MockRead(false, 1, "HTTP/1.1 302 OK\r\n"), |
| 435 MockRead(false, 2, "Content-Length: 8\r\n\r\n"), |
| 436 MockRead(true, 4, "redirect"), |
| 437 MockRead(false, 5, "HTTP/1.1 200 OK\r\n"), |
| 438 MockRead(false, 6, "Content-Length: 8\r\n\r\n"), |
| 439 MockRead(false, 7, "two.html"), |
| 440 }; |
| 441 AddExpectedConnection(reads, arraysize(reads), writes, arraysize(writes)); |
| 442 |
| 443 scoped_ptr<HttpNetworkTransaction> one_transaction( |
| 444 new HttpNetworkTransaction(session_.get())); |
| 445 TestOldCompletionCallback one_callback; |
| 446 EXPECT_EQ(ERR_IO_PENDING, |
| 447 one_transaction->Start(GetRequestInfo("redirect.html"), |
| 448 &one_callback, BoundNetLog())); |
| 449 EXPECT_EQ(OK, one_callback.WaitForResult()); |
| 450 |
| 451 HttpNetworkTransaction two_transaction(session_.get()); |
| 452 TestOldCompletionCallback two_callback; |
| 453 EXPECT_EQ(ERR_IO_PENDING, |
| 454 two_transaction.Start(GetRequestInfo("two.html"), &two_callback, |
| 455 BoundNetLog())); |
| 456 |
| 457 one_transaction.reset(); |
| 458 data_vector_[0]->RunFor(2); |
| 459 data_vector_[0]->SetStop(10); |
| 460 |
| 461 EXPECT_EQ(OK, two_callback.WaitForResult()); |
| 462 ExpectResponse("two.html", two_transaction); |
| 463 } |
| 464 |
422 TEST_F(HttpPipelinedNetworkTransactionTest, BasicHttpAuthentication) { | 465 TEST_F(HttpPipelinedNetworkTransactionTest, BasicHttpAuthentication) { |
423 Initialize(); | 466 Initialize(); |
424 | 467 |
425 MockWrite writes[] = { | 468 MockWrite writes[] = { |
426 MockWrite(false, 0, "GET /one.html HTTP/1.1\r\n" | 469 MockWrite(false, 0, "GET /one.html HTTP/1.1\r\n" |
427 "Host: localhost\r\n" | 470 "Host: localhost\r\n" |
428 "Connection: keep-alive\r\n\r\n"), | 471 "Connection: keep-alive\r\n\r\n"), |
429 MockWrite(false, 5, "GET /one.html HTTP/1.1\r\n" | 472 MockWrite(false, 5, "GET /one.html HTTP/1.1\r\n" |
430 "Host: localhost\r\n" | 473 "Host: localhost\r\n" |
431 "Connection: keep-alive\r\n" | 474 "Connection: keep-alive\r\n" |
(...skipping 29 matching lines...) Expand all Loading... |
461 | 504 |
462 AuthCredentials credentials(ASCIIToUTF16("user"), ASCIIToUTF16("pass")); | 505 AuthCredentials credentials(ASCIIToUTF16("user"), ASCIIToUTF16("pass")); |
463 EXPECT_EQ(OK, transaction.RestartWithAuth(credentials, &callback_)); | 506 EXPECT_EQ(OK, transaction.RestartWithAuth(credentials, &callback_)); |
464 | 507 |
465 ExpectResponse("one.html", transaction); | 508 ExpectResponse("one.html", transaction); |
466 } | 509 } |
467 | 510 |
468 } // anonymous namespace | 511 } // anonymous namespace |
469 | 512 |
470 } // namespace net | 513 } // namespace net |
OLD | NEW |