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

Side by Side Diff: net/websockets/websocket_stream_test.cc

Issue 902553002: Change error message for WebSocket tunnel failure. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix memory leak and simplify SetProxyService() Created 5 years, 10 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
« no previous file with comments | « net/websockets/websocket_stream.cc ('k') | net/websockets/websocket_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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/websockets/websocket_stream.h" 5 #include "net/websockets/websocket_stream.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/compiler_specific.h" 12 #include "base/compiler_specific.h"
13 #include "base/memory/scoped_vector.h" 13 #include "base/memory/scoped_vector.h"
14 #include "base/metrics/histogram.h" 14 #include "base/metrics/histogram.h"
15 #include "base/metrics/histogram_samples.h" 15 #include "base/metrics/histogram_samples.h"
16 #include "base/metrics/statistics_recorder.h" 16 #include "base/metrics/statistics_recorder.h"
17 #include "base/run_loop.h" 17 #include "base/run_loop.h"
18 #include "base/strings/stringprintf.h" 18 #include "base/strings/stringprintf.h"
19 #include "base/timer/mock_timer.h" 19 #include "base/timer/mock_timer.h"
20 #include "base/timer/timer.h" 20 #include "base/timer/timer.h"
21 #include "net/base/net_errors.h" 21 #include "net/base/net_errors.h"
22 #include "net/base/test_data_directory.h" 22 #include "net/base/test_data_directory.h"
23 #include "net/http/http_request_headers.h" 23 #include "net/http/http_request_headers.h"
24 #include "net/http/http_response_headers.h" 24 #include "net/http/http_response_headers.h"
25 #include "net/proxy/proxy_service.h"
25 #include "net/socket/client_socket_handle.h" 26 #include "net/socket/client_socket_handle.h"
26 #include "net/socket/socket_test_util.h" 27 #include "net/socket/socket_test_util.h"
27 #include "net/test/cert_test_util.h" 28 #include "net/test/cert_test_util.h"
28 #include "net/url_request/url_request_test_util.h" 29 #include "net/url_request/url_request_test_util.h"
29 #include "net/websockets/websocket_basic_handshake_stream.h" 30 #include "net/websockets/websocket_basic_handshake_stream.h"
30 #include "net/websockets/websocket_frame.h" 31 #include "net/websockets/websocket_frame.h"
31 #include "net/websockets/websocket_handshake_request_info.h" 32 #include "net/websockets/websocket_handshake_request_info.h"
32 #include "net/websockets/websocket_handshake_response_info.h" 33 #include "net/websockets/websocket_handshake_response_info.h"
33 #include "net/websockets/websocket_handshake_stream_create_helper.h" 34 #include "net/websockets/websocket_handshake_stream_create_helper.h"
34 #include "net/websockets/websocket_test_util.h" 35 #include "net/websockets/websocket_test_util.h"
(...skipping 1370 matching lines...) Expand 10 before | Expand all | Expand 10 after
1405 MockWrite writes[] = {MockWrite(SYNCHRONOUS, 0, request.c_str())}; 1406 MockWrite writes[] = {MockWrite(SYNCHRONOUS, 0, request.c_str())};
1406 scoped_ptr<DeterministicSocketData> socket_data( 1407 scoped_ptr<DeterministicSocketData> socket_data(
1407 BuildSocketData(reads, writes)); 1408 BuildSocketData(reads, writes));
1408 socket_data->set_connect_data(MockConnect(SYNCHRONOUS, OK)); 1409 socket_data->set_connect_data(MockConnect(SYNCHRONOUS, OK));
1409 CreateAndConnectRawExpectations("ws://localhost/", NoSubProtocols(), 1410 CreateAndConnectRawExpectations("ws://localhost/", NoSubProtocols(),
1410 "http://localhost", socket_data.Pass()); 1411 "http://localhost", socket_data.Pass());
1411 RunUntilIdle(); 1412 RunUntilIdle();
1412 EXPECT_TRUE(has_failed()); 1413 EXPECT_TRUE(has_failed());
1413 } 1414 }
1414 1415
1416 TEST_F(WebSocketStreamCreateTest, HandleErrTunnelConnectionFailed) {
1417 static const char kConnectRequest[] =
1418 "CONNECT localhost:80 HTTP/1.1\r\n"
1419 "Host: localhost\r\n"
1420 "Proxy-Connection: keep-alive\r\n"
1421 "\r\n";
1422
1423 static const char kProxyResponse[] =
1424 "HTTP/1.1 403 Forbidden\r\n"
1425 "Content-Type: text/html\r\n"
1426 "Content-Length: 9\r\n"
1427 "Connection: keep-alive\r\n"
1428 "\r\n"
1429 "Forbidden";
1430
1431 MockRead reads[] = {MockRead(SYNCHRONOUS, 1, kProxyResponse)};
1432 MockWrite writes[] = {MockWrite(SYNCHRONOUS, 0, kConnectRequest)};
1433 scoped_ptr<DeterministicSocketData> socket_data(
1434 BuildSocketData(reads, writes));
1435 url_request_context_host_.SetProxyConfig("https=proxy:8000");
1436 CreateAndConnectRawExpectations("ws://localhost/", NoSubProtocols(),
1437 "http://localhost", socket_data.Pass());
1438 RunUntilIdle();
1439 EXPECT_TRUE(has_failed());
1440 EXPECT_EQ("Establishing a tunnel via proxy server failed.",
1441 failure_message());
1442 }
1443
1415 } // namespace 1444 } // namespace
1416 } // namespace net 1445 } // namespace net
OLDNEW
« no previous file with comments | « net/websockets/websocket_stream.cc ('k') | net/websockets/websocket_test_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698