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 #ifndef NET_WEBSOCKETS_WEBSOCKET_TEST_UTIL_H_ | 5 #ifndef NET_WEBSOCKETS_WEBSOCKET_TEST_UTIL_H_ |
6 #define NET_WEBSOCKETS_WEBSOCKET_TEST_UTIL_H_ | 6 #define NET_WEBSOCKETS_WEBSOCKET_TEST_UTIL_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
(...skipping 27 matching lines...) Expand all Loading... |
38 explicit LinearCongruentialGenerator(uint32_t seed); | 38 explicit LinearCongruentialGenerator(uint32_t seed); |
39 uint32_t Generate(); | 39 uint32_t Generate(); |
40 | 40 |
41 private: | 41 private: |
42 uint64_t current_; | 42 uint64_t current_; |
43 }; | 43 }; |
44 | 44 |
45 // Generates a standard WebSocket handshake request. The challenge key used is | 45 // Generates a standard WebSocket handshake request. The challenge key used is |
46 // "dGhlIHNhbXBsZSBub25jZQ==". Each header in |extra_headers| must be terminated | 46 // "dGhlIHNhbXBsZSBub25jZQ==". Each header in |extra_headers| must be terminated |
47 // with "\r\n". | 47 // with "\r\n". |
48 std::string WebSocketStandardRequest(const std::string& path, | 48 std::string WebSocketStandardRequest( |
49 const std::string& host, | 49 const std::string& path, |
50 const url::Origin& origin, | 50 const std::string& host, |
51 const std::string& extra_headers); | 51 const url::Origin& origin, |
| 52 const std::string& send_additional_request_headers, |
| 53 const std::string& extra_headers); |
52 | 54 |
53 // Generates a standard WebSocket handshake request. The challenge key used is | 55 // Generates a standard WebSocket handshake request. The challenge key used is |
54 // "dGhlIHNhbXBsZSBub25jZQ==". |cookies| must be empty or terminated with | 56 // "dGhlIHNhbXBsZSBub25jZQ==". |cookies| must be empty or terminated with |
55 // "\r\n". Each header in |extra_headers| must be terminated with "\r\n". | 57 // "\r\n". Each header in |extra_headers| must be terminated with "\r\n". |
56 std::string WebSocketStandardRequestWithCookies( | 58 std::string WebSocketStandardRequestWithCookies( |
57 const std::string& path, | 59 const std::string& path, |
58 const std::string& host, | 60 const std::string& host, |
59 const url::Origin& origin, | 61 const url::Origin& origin, |
60 const std::string& cookies, | 62 const std::string& cookies, |
| 63 const std::string& send_additional_request_headers, |
61 const std::string& extra_headers); | 64 const std::string& extra_headers); |
62 | 65 |
63 // A response with the appropriate accept header to match the above challenge | 66 // A response with the appropriate accept header to match the above challenge |
64 // key. Each header in |extra_headers| must be terminated with "\r\n". | 67 // key. Each header in |extra_headers| must be terminated with "\r\n". |
65 std::string WebSocketStandardResponse(const std::string& extra_headers); | 68 std::string WebSocketStandardResponse(const std::string& extra_headers); |
66 | 69 |
67 // This class provides a convenient way to construct a MockClientSocketFactory | 70 // This class provides a convenient way to construct a MockClientSocketFactory |
68 // for WebSocket tests. | 71 // for WebSocket tests. |
69 class WebSocketMockClientSocketFactoryMaker { | 72 class WebSocketMockClientSocketFactoryMaker { |
70 public: | 73 public: |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 TestNetworkDelegate network_delegate_; | 140 TestNetworkDelegate network_delegate_; |
138 std::unique_ptr<ProxyService> proxy_service_; | 141 std::unique_ptr<ProxyService> proxy_service_; |
139 bool url_request_context_initialized_; | 142 bool url_request_context_initialized_; |
140 | 143 |
141 DISALLOW_COPY_AND_ASSIGN(WebSocketTestURLRequestContextHost); | 144 DISALLOW_COPY_AND_ASSIGN(WebSocketTestURLRequestContextHost); |
142 }; | 145 }; |
143 | 146 |
144 } // namespace net | 147 } // namespace net |
145 | 148 |
146 #endif // NET_WEBSOCKETS_WEBSOCKET_TEST_UTIL_H_ | 149 #endif // NET_WEBSOCKETS_WEBSOCKET_TEST_UTIL_H_ |
OLD | NEW |