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

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

Issue 2669313002: Revert of Allow proxying plaintext websockets over http/2 proxy (Closed)
Patch Set: Created 3 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 | « no previous file | net/http/http_stream_factory_impl_job.cc » ('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/http/http_network_transaction.h" 5 #include "net/http/http_network_transaction.h"
6 6
7 #include <math.h> // ceil 7 #include <math.h> // ceil
8 #include <stdarg.h> 8 #include <stdarg.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
(...skipping 16495 matching lines...) Expand 10 before | Expand all | Expand 10 after
16506 trans.Start(&request, callback.callback(), NetLogWithSource())); 16506 trans.Start(&request, callback.callback(), NetLogWithSource()));
16507 base::RunLoop().RunUntilIdle(); 16507 base::RunLoop().RunUntilIdle();
16508 16508
16509 EXPECT_TRUE(trans.GetResponseInfo()->was_fetched_via_spdy); 16509 EXPECT_TRUE(trans.GetResponseInfo()->was_fetched_via_spdy);
16510 HttpRequestHeaders headers; 16510 HttpRequestHeaders headers;
16511 ASSERT_TRUE(trans.GetFullRequestHeaders(&headers)); 16511 ASSERT_TRUE(trans.GetFullRequestHeaders(&headers));
16512 EXPECT_TRUE(headers.HasHeader(HttpRequestHeaders::kTokenBinding)); 16512 EXPECT_TRUE(headers.HasHeader(HttpRequestHeaders::kTokenBinding));
16513 } 16513 }
16514 #endif // !defined(OS_IOS) 16514 #endif // !defined(OS_IOS)
16515 16515
16516 // Test a SPDY CONNECT through an HTTPS Proxy to plaintext WebSocket Server.
16517 TEST_F(HttpNetworkTransactionTest, PlaintextWebsocketOverSpdyProxy) {
16518 HttpRequestInfo request;
16519 request.method = "GET";
16520 request.url = GURL("ws://www.example.org/");
16521 AddWebSocketHeaders(&request.extra_headers);
16522
16523 // Configure against https proxy server "proxy:70".
16524 session_deps_.proxy_service = ProxyService::CreateFixed("https://proxy:70");
16525 BoundTestNetLog log;
16526 session_deps_.net_log = log.bound().net_log();
16527 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_));
16528
16529 HttpNetworkTransaction trans(DEFAULT_PRIORITY, session.get());
16530 FakeWebSocketStreamCreateHelper websocket_stream_create_helper;
16531 trans.SetWebSocketHandshakeStreamCreateHelper(
16532 &websocket_stream_create_helper);
16533
16534 // CONNECT to www.example.org:443 via SPDY
16535 SpdySerializedFrame connect(spdy_util_.ConstructSpdyConnect(
16536 nullptr, 0, 1, LOWEST, HostPortPair("www.example.org", 80)));
16537 const char req[] =
16538 "GET / HTTP/1.1\r\n"
16539 "Host: www.example.org\r\n"
16540 "Connection: Upgrade\r\n"
16541 "Upgrade: websocket\r\n"
16542 "Origin: http://www.example.org\r\n"
16543 "Sec-WebSocket-Version: 13\r\n"
16544 "Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==\r\n\r\n";
16545 SpdySerializedFrame wrapped_ws_req(
16546 spdy_util_.ConstructSpdyDataFrame(1, req, strlen(req), false));
16547 SpdySerializedFrame conn_resp(
16548 spdy_util_.ConstructSpdyGetReply(nullptr, 0, 1));
16549 const char resp[] =
16550 "HTTP/1.1 101 Switching Protocols\r\n"
16551 "Upgrade: websocket\r\n"
16552 "Connection: Upgrade\r\n"
16553 "Sec-WebSocket-Accept: s3pPLMBiTxaQ9kYGzzhZRbK+xOo=\r\n\r\n";
16554 SpdySerializedFrame wrapped_ws_resp(
16555 spdy_util_.ConstructSpdyDataFrame(1, resp, strlen(resp), false));
16556 SpdySerializedFrame window_update(
16557 spdy_util_.ConstructSpdyWindowUpdate(1, wrapped_ws_resp.size()));
16558
16559 MockWrite spdy_writes[] = {
16560 CreateMockWrite(connect, 0), CreateMockWrite(wrapped_ws_req, 2),
16561 CreateMockWrite(window_update, 4),
16562 };
16563
16564 MockRead spdy_reads[] = {
16565 CreateMockRead(conn_resp, 1, ASYNC),
16566 CreateMockRead(wrapped_ws_resp, 3, ASYNC), MockRead(ASYNC, 0, 5),
16567 };
16568
16569 SequencedSocketData spdy_data(spdy_reads, arraysize(spdy_reads), spdy_writes,
16570 arraysize(spdy_writes));
16571 session_deps_.socket_factory->AddSocketDataProvider(&spdy_data);
16572
16573 SSLSocketDataProvider ssl(ASYNC, OK);
16574 ssl.next_proto = kProtoHTTP2;
16575 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl);
16576
16577 TestCompletionCallback callback;
16578
16579 int rv = trans.Start(&request, callback.callback(), log.bound());
16580 EXPECT_THAT(rv, IsError(ERR_IO_PENDING));
16581
16582 rv = callback.WaitForResult();
16583 ASSERT_THAT(rv, IsOk());
16584
16585 const HttpResponseInfo* response = trans.GetResponseInfo();
16586 ASSERT_TRUE(response);
16587 ASSERT_TRUE(response->headers);
16588 EXPECT_EQ("HTTP/1.1 101 Switching Protocols",
16589 response->headers->GetStatusLine());
16590 }
16591
16592 } // namespace net 16516 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | net/http/http_stream_factory_impl_job.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698