| OLD | NEW |
| 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> |
| (...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 309 "GET / HTTP/1.1\r\n" | 309 "GET / HTTP/1.1\r\n" |
| 310 "Host: localhost\r\n" | 310 "Host: localhost\r\n" |
| 311 "Connection: Upgrade\r\n" | 311 "Connection: Upgrade\r\n" |
| 312 "Pragma: no-cache\r\n" | 312 "Pragma: no-cache\r\n" |
| 313 "Cache-Control: no-cache\r\n" | 313 "Cache-Control: no-cache\r\n" |
| 314 "Authorization: Basic %s\r\n" | 314 "Authorization: Basic %s\r\n" |
| 315 "Upgrade: websocket\r\n" | 315 "Upgrade: websocket\r\n" |
| 316 "Origin: http://localhost\r\n" | 316 "Origin: http://localhost\r\n" |
| 317 "Sec-WebSocket-Version: 13\r\n" | 317 "Sec-WebSocket-Version: 13\r\n" |
| 318 "User-Agent:\r\n" | 318 "User-Agent:\r\n" |
| 319 "Accept-Encoding: gzip,deflate\r\n" | 319 "Accept-Encoding: gzip, deflate\r\n" |
| 320 "Accept-Language: en-us,fr\r\n" | 320 "Accept-Language: en-us,fr\r\n" |
| 321 "Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==\r\n" | 321 "Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==\r\n" |
| 322 "Sec-WebSocket-Extensions: permessage-deflate; " | 322 "Sec-WebSocket-Extensions: permessage-deflate; " |
| 323 "client_max_window_bits\r\n" | 323 "client_max_window_bits\r\n" |
| 324 "\r\n"; | 324 "\r\n"; |
| 325 const std::string request = | 325 const std::string request = |
| 326 base::StringPrintf(request2format, base64_user_pass.c_str()); | 326 base::StringPrintf(request2format, base64_user_pass.c_str()); |
| 327 CreateAndConnectRawExpectations( | 327 CreateAndConnectRawExpectations( |
| 328 url, | 328 url, |
| 329 NoSubProtocols(), | 329 NoSubProtocols(), |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 366 "Connection: Upgrade\r\n" | 366 "Connection: Upgrade\r\n" |
| 367 "Pragma: no-cache\r\n" | 367 "Pragma: no-cache\r\n" |
| 368 "Cache-Control: no-cache\r\n" | 368 "Cache-Control: no-cache\r\n" |
| 369 "Authorization: Digest username=\"FooBar\", realm=\"Oblivion\", " | 369 "Authorization: Digest username=\"FooBar\", realm=\"Oblivion\", " |
| 370 "nonce=\"nonce-value\", uri=\"/\", " | 370 "nonce=\"nonce-value\", uri=\"/\", " |
| 371 "response=\"f72ff54ebde2f928860f806ec04acd1b\"\r\n" | 371 "response=\"f72ff54ebde2f928860f806ec04acd1b\"\r\n" |
| 372 "Upgrade: websocket\r\n" | 372 "Upgrade: websocket\r\n" |
| 373 "Origin: http://localhost\r\n" | 373 "Origin: http://localhost\r\n" |
| 374 "Sec-WebSocket-Version: 13\r\n" | 374 "Sec-WebSocket-Version: 13\r\n" |
| 375 "User-Agent:\r\n" | 375 "User-Agent:\r\n" |
| 376 "Accept-Encoding: gzip,deflate\r\n" | 376 "Accept-Encoding: gzip, deflate\r\n" |
| 377 "Accept-Language: en-us,fr\r\n" | 377 "Accept-Language: en-us,fr\r\n" |
| 378 "Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==\r\n" | 378 "Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==\r\n" |
| 379 "Sec-WebSocket-Extensions: permessage-deflate; " | 379 "Sec-WebSocket-Extensions: permessage-deflate; " |
| 380 "client_max_window_bits\r\n" | 380 "client_max_window_bits\r\n" |
| 381 "\r\n"; | 381 "\r\n"; |
| 382 | 382 |
| 383 class WebSocketStreamCreateUMATest : public ::testing::Test { | 383 class WebSocketStreamCreateUMATest : public ::testing::Test { |
| 384 public: | 384 public: |
| 385 // This enum should match with the enum in Delegate in websocket_stream.cc. | 385 // This enum should match with the enum in Delegate in websocket_stream.cc. |
| 386 enum HandshakeResult { | 386 enum HandshakeResult { |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 452 EXPECT_EQ(HeaderKeyValuePair("Connection", "Upgrade"), request_headers[1]); | 452 EXPECT_EQ(HeaderKeyValuePair("Connection", "Upgrade"), request_headers[1]); |
| 453 EXPECT_EQ(HeaderKeyValuePair("Pragma", "no-cache"), request_headers[2]); | 453 EXPECT_EQ(HeaderKeyValuePair("Pragma", "no-cache"), request_headers[2]); |
| 454 EXPECT_EQ(HeaderKeyValuePair("Cache-Control", "no-cache"), | 454 EXPECT_EQ(HeaderKeyValuePair("Cache-Control", "no-cache"), |
| 455 request_headers[3]); | 455 request_headers[3]); |
| 456 EXPECT_EQ(HeaderKeyValuePair("Upgrade", "websocket"), request_headers[4]); | 456 EXPECT_EQ(HeaderKeyValuePair("Upgrade", "websocket"), request_headers[4]); |
| 457 EXPECT_EQ(HeaderKeyValuePair("Origin", "http://localhost"), | 457 EXPECT_EQ(HeaderKeyValuePair("Origin", "http://localhost"), |
| 458 request_headers[5]); | 458 request_headers[5]); |
| 459 EXPECT_EQ(HeaderKeyValuePair("Sec-WebSocket-Version", "13"), | 459 EXPECT_EQ(HeaderKeyValuePair("Sec-WebSocket-Version", "13"), |
| 460 request_headers[6]); | 460 request_headers[6]); |
| 461 EXPECT_EQ(HeaderKeyValuePair("User-Agent", ""), request_headers[7]); | 461 EXPECT_EQ(HeaderKeyValuePair("User-Agent", ""), request_headers[7]); |
| 462 EXPECT_EQ(HeaderKeyValuePair("Accept-Encoding", "gzip,deflate"), | 462 EXPECT_EQ(HeaderKeyValuePair("Accept-Encoding", "gzip, deflate"), |
| 463 request_headers[8]); | 463 request_headers[8]); |
| 464 EXPECT_EQ(HeaderKeyValuePair("Accept-Language", "en-us,fr"), | 464 EXPECT_EQ(HeaderKeyValuePair("Accept-Language", "en-us,fr"), |
| 465 request_headers[9]); | 465 request_headers[9]); |
| 466 EXPECT_EQ("Sec-WebSocket-Key", request_headers[10].first); | 466 EXPECT_EQ("Sec-WebSocket-Key", request_headers[10].first); |
| 467 EXPECT_EQ(HeaderKeyValuePair("Sec-WebSocket-Extensions", | 467 EXPECT_EQ(HeaderKeyValuePair("Sec-WebSocket-Extensions", |
| 468 "permessage-deflate; client_max_window_bits"), | 468 "permessage-deflate; client_max_window_bits"), |
| 469 request_headers[11]); | 469 request_headers[11]); |
| 470 | 470 |
| 471 std::vector<HeaderKeyValuePair> response_headers = | 471 std::vector<HeaderKeyValuePair> response_headers = |
| 472 ToVector(*response_info_->headers.get()); | 472 ToVector(*response_info_->headers.get()); |
| (...skipping 894 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1367 if (original) { | 1367 if (original) { |
| 1368 samples->Subtract(*original); // Cancel the original values. | 1368 samples->Subtract(*original); // Cancel the original values. |
| 1369 } | 1369 } |
| 1370 EXPECT_EQ(1, samples->GetCount(INCOMPLETE)); | 1370 EXPECT_EQ(1, samples->GetCount(INCOMPLETE)); |
| 1371 EXPECT_EQ(0, samples->GetCount(CONNECTED)); | 1371 EXPECT_EQ(0, samples->GetCount(CONNECTED)); |
| 1372 EXPECT_EQ(0, samples->GetCount(FAILED)); | 1372 EXPECT_EQ(0, samples->GetCount(FAILED)); |
| 1373 } | 1373 } |
| 1374 | 1374 |
| 1375 } // namespace | 1375 } // namespace |
| 1376 } // namespace net | 1376 } // namespace net |
| OLD | NEW |