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

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

Issue 25312002: net: don't preserve 1xx responses in parser buffer. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: .. Created 7 years, 2 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 | « no previous file | net/http/http_stream_parser.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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/http/http_proxy_client_socket_pool.h" 5 #include "net/http/http_proxy_client_socket_pool.h"
6 6
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/strings/string_util.h" 9 #include "base/strings/string_util.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 546 matching lines...) Expand 10 before | Expand all | Expand 10 after
557 // SPDY cannot process a headers block unless it's complete and so it 557 // SPDY cannot process a headers block unless it's complete and so it
558 // returns ERR_CONNECTION_CLOSED in this case. 558 // returns ERR_CONNECTION_CLOSED in this case.
559 EXPECT_EQ(ERR_CONNECTION_CLOSED, callback_.WaitForResult()); 559 EXPECT_EQ(ERR_CONNECTION_CLOSED, callback_.WaitForResult());
560 } else { 560 } else {
561 EXPECT_EQ(ERR_RESPONSE_HEADERS_TRUNCATED, callback_.WaitForResult()); 561 EXPECT_EQ(ERR_RESPONSE_HEADERS_TRUNCATED, callback_.WaitForResult());
562 } 562 }
563 EXPECT_FALSE(handle_.is_initialized()); 563 EXPECT_FALSE(handle_.is_initialized());
564 EXPECT_FALSE(handle_.socket()); 564 EXPECT_FALSE(handle_.socket());
565 } 565 }
566 566
567 TEST_P(HttpProxyClientSocketPoolTest, Tunnel1xxResponse) {
568 // Tests that 1xx responses are rejected for a CONNECT request.
569 if (GetParam().proxy_type == SPDY) {
570 // SPDY doesn't have 1xx responses.
571 return;
572 }
573
574 MockWrite writes[] = {
575 MockWrite(ASYNC, 0,
576 "CONNECT www.google.com:443 HTTP/1.1\r\n"
577 "Host: www.google.com\r\n"
578 "Proxy-Connection: keep-alive\r\n\r\n"),
579 };
580 MockRead reads[] = {
581 MockRead(ASYNC, 1, "HTTP/1.1 100 Continue\r\n\r\n"),
582 MockRead(ASYNC, 2, "HTTP/1.1 200 Connection Established\r\n\r\n"),
583 };
584
585 Initialize(reads, arraysize(reads), writes, arraysize(writes),
586 NULL, 0, NULL, 0);
587
588 int rv = handle_.Init("a", CreateTunnelParams(), LOW, callback_.callback(),
589 &pool_, BoundNetLog());
590 EXPECT_EQ(ERR_IO_PENDING, rv);
591 EXPECT_FALSE(handle_.is_initialized());
592 EXPECT_FALSE(handle_.socket());
593
594 data_->RunFor(2);
595 EXPECT_EQ(ERR_TUNNEL_CONNECTION_FAILED, callback_.WaitForResult());
596 }
597
567 TEST_P(HttpProxyClientSocketPoolTest, TunnelSetupError) { 598 TEST_P(HttpProxyClientSocketPoolTest, TunnelSetupError) {
568 MockWrite writes[] = { 599 MockWrite writes[] = {
569 MockWrite(ASYNC, 0, 600 MockWrite(ASYNC, 0,
570 "CONNECT www.google.com:443 HTTP/1.1\r\n" 601 "CONNECT www.google.com:443 HTTP/1.1\r\n"
571 "Host: www.google.com\r\n" 602 "Host: www.google.com\r\n"
572 "Proxy-Connection: keep-alive\r\n" 603 "Proxy-Connection: keep-alive\r\n"
573 "Proxy-Authorization: Basic Zm9vOmJhcg==\r\n\r\n"), 604 "Proxy-Authorization: Basic Zm9vOmJhcg==\r\n\r\n"),
574 }; 605 };
575 MockRead reads[] = { 606 MockRead reads[] = {
576 MockRead(ASYNC, 1, "HTTP/1.1 304 Not Modified\r\n\r\n"), 607 MockRead(ASYNC, 1, "HTTP/1.1 304 Not Modified\r\n\r\n"),
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
693 EXPECT_TRUE(headers->IsRedirect(&location)); 724 EXPECT_TRUE(headers->IsRedirect(&location));
694 EXPECT_EQ(location, redirectTarget); 725 EXPECT_EQ(location, redirectTarget);
695 } 726 }
696 } 727 }
697 728
698 // It would be nice to also test the timeouts in HttpProxyClientSocketPool. 729 // It would be nice to also test the timeouts in HttpProxyClientSocketPool.
699 730
700 } // namespace 731 } // namespace
701 732
702 } // namespace net 733 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | net/http/http_stream_parser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698