| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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_SPDY_SPDY_WEBSOCKET_TEST_UTIL_H_ | 5 #ifndef NET_SPDY_SPDY_WEBSOCKET_TEST_UTIL_H_ |
| 6 #define NET_SPDY_SPDY_WEBSOCKET_TEST_UTIL_H_ | 6 #define NET_SPDY_SPDY_WEBSOCKET_TEST_UTIL_H_ |
| 7 | 7 |
| 8 #include "net/base/request_priority.h" | 8 #include "net/base/request_priority.h" |
| 9 #include "net/spdy/spdy_header_block.h" |
| 9 #include "net/spdy/spdy_protocol.h" | 10 #include "net/spdy/spdy_protocol.h" |
| 10 #include "net/spdy/spdy_test_util_common.h" | 11 #include "net/spdy/spdy_test_util_common.h" |
| 11 | 12 |
| 12 namespace net { | 13 namespace net { |
| 13 | 14 |
| 14 class SpdyWebSocketTestUtil { | 15 class SpdyWebSocketTestUtil { |
| 15 public: | 16 public: |
| 16 explicit SpdyWebSocketTestUtil(NextProto protocol); | 17 explicit SpdyWebSocketTestUtil(NextProto protocol); |
| 17 | 18 |
| 18 // Adds the given key/value pair to |headers|, tweaking it depending | 19 // Returns the value corresponding to the given key (passed through |
| 19 // on SPDY version. | 20 // GetHeaderKey()), or the empty string if none exists. |
| 21 std::string GetHeader(const SpdyHeaderBlock& headers, |
| 22 const std::string& key) const; |
| 23 |
| 24 // Adds the given key/value pair to |headers|, passing the key |
| 25 // through GetHeaderKey(). |
| 20 void SetHeader(const std::string& key, | 26 void SetHeader(const std::string& key, |
| 21 const std::string& value, | 27 const std::string& value, |
| 22 SpdyHeaderBlock* headers) const; | 28 SpdyHeaderBlock* headers) const; |
| 23 | 29 |
| 24 // Constructs a standard SPDY SYN_STREAM frame for WebSocket over | 30 // Constructs a standard SPDY SYN_STREAM frame for WebSocket over |
| 25 // SPDY opening handshake. | 31 // SPDY opening handshake. |
| 26 SpdyFrame* ConstructSpdyWebSocketSynStream(int stream_id, | 32 SpdyFrame* ConstructSpdyWebSocketSynStream(int stream_id, |
| 27 const char* path, | 33 const char* path, |
| 28 const char* host, | 34 const char* host, |
| 29 const char* origin); | 35 const char* origin); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 50 bool fin); | 56 bool fin); |
| 51 | 57 |
| 52 // Constructs a WebSocket over SPDY data packet. | 58 // Constructs a WebSocket over SPDY data packet. |
| 53 SpdyFrame* ConstructSpdyWebSocketDataFrame(const char* data, | 59 SpdyFrame* ConstructSpdyWebSocketDataFrame(const char* data, |
| 54 int len, | 60 int len, |
| 55 SpdyStreamId stream_id, | 61 SpdyStreamId stream_id, |
| 56 bool fin); | 62 bool fin); |
| 57 | 63 |
| 58 // Forwards to |spdy_util_|. | 64 // Forwards to |spdy_util_|. |
| 59 SpdyFrame* ConstructSpdySettings(const SettingsMap& settings) const; | 65 SpdyFrame* ConstructSpdySettings(const SettingsMap& settings) const; |
| 66 SpdyMajorVersion spdy_version() const; |
| 60 | 67 |
| 61 private: | 68 private: |
| 69 // Modify the header key based on the SPDY version and return it. |
| 70 std::string GetHeaderKey(const std::string& key) const; |
| 71 |
| 62 SpdyTestUtil spdy_util_; | 72 SpdyTestUtil spdy_util_; |
| 63 }; | 73 }; |
| 64 | 74 |
| 65 } // namespace net | 75 } // namespace net |
| 66 | 76 |
| 67 #endif // NET_SPDY_SPDY_WEBSOCKET_TEST_UTIL_H_ | 77 #endif // NET_SPDY_SPDY_WEBSOCKET_TEST_UTIL_H_ |
| OLD | NEW |