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

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: g try 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') | net/http/http_stream_parser.cc » ('J')
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"
579 "Proxy-Authorization: Basic Zm9vOmJhcg==\r\n\r\n"),
wtc 2013/10/01 18:12:57 Nit: Is the Proxy-Authorization header (and the Ad
agl 2013/10/01 19:53:18 Done.
580 };
581 MockRead reads[] = {
582 MockRead(ASYNC, 1, "HTTP/1.1 100 Continue\r\n\r\n"),
583 MockRead(ASYNC, 2, "HTTP/1.1 200 Connection Established\r\n\r\n"),
584 };
585
586 Initialize(reads, arraysize(reads), writes, arraysize(writes),
587 NULL, 0, NULL, 0);
588 AddAuthToCache();
589
590 int rv = handle_.Init("a", CreateTunnelParams(), LOW, callback_.callback(),
591 &pool_, BoundNetLog());
592 EXPECT_EQ(ERR_IO_PENDING, rv);
593 EXPECT_FALSE(handle_.is_initialized());
594 EXPECT_FALSE(handle_.socket());
595
596 data_->RunFor(2);
597 EXPECT_EQ(ERR_TUNNEL_CONNECTION_FAILED, callback_.WaitForResult());
598 }
599
567 TEST_P(HttpProxyClientSocketPoolTest, TunnelSetupError) { 600 TEST_P(HttpProxyClientSocketPoolTest, TunnelSetupError) {
568 MockWrite writes[] = { 601 MockWrite writes[] = {
569 MockWrite(ASYNC, 0, 602 MockWrite(ASYNC, 0,
570 "CONNECT www.google.com:443 HTTP/1.1\r\n" 603 "CONNECT www.google.com:443 HTTP/1.1\r\n"
571 "Host: www.google.com\r\n" 604 "Host: www.google.com\r\n"
572 "Proxy-Connection: keep-alive\r\n" 605 "Proxy-Connection: keep-alive\r\n"
573 "Proxy-Authorization: Basic Zm9vOmJhcg==\r\n\r\n"), 606 "Proxy-Authorization: Basic Zm9vOmJhcg==\r\n\r\n"),
574 }; 607 };
575 MockRead reads[] = { 608 MockRead reads[] = {
576 MockRead(ASYNC, 1, "HTTP/1.1 304 Not Modified\r\n\r\n"), 609 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)); 726 EXPECT_TRUE(headers->IsRedirect(&location));
694 EXPECT_EQ(location, redirectTarget); 727 EXPECT_EQ(location, redirectTarget);
695 } 728 }
696 } 729 }
697 730
698 // It would be nice to also test the timeouts in HttpProxyClientSocketPool. 731 // It would be nice to also test the timeouts in HttpProxyClientSocketPool.
699 732
700 } // namespace 733 } // namespace
701 734
702 } // namespace net 735 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | net/http/http_stream_parser.h » ('j') | net/http/http_stream_parser.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698