OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef NET_WEBSOCKETS_WEBSOCKET_HANDSHAKE_DRAFT75_H_ |
| 6 #define NET_WEBSOCKETS_WEBSOCKET_HANDSHAKE_DRAFT75_H_ |
| 7 |
| 8 #include <string> |
| 9 |
| 10 #include "base/basictypes.h" |
| 11 #include "googleurl/src/gurl.h" |
| 12 #include "net/websockets/websocket_handshake.h" |
| 13 |
| 14 namespace net { |
| 15 |
| 16 class HttpResponseHeaders; |
| 17 |
| 18 class WebSocketHandshakeDraft75 : public WebSocketHandshake { |
| 19 public: |
| 20 static const int kWebSocketPort; |
| 21 static const int kSecureWebSocketPort; |
| 22 static const char kServerHandshakeHeader[]; |
| 23 static const size_t kServerHandshakeHeaderLength; |
| 24 static const char kUpgradeHeader[]; |
| 25 static const size_t kUpgradeHeaderLength; |
| 26 static const char kConnectionHeader[]; |
| 27 static const size_t kConnectionHeaderLength; |
| 28 |
| 29 WebSocketHandshakeDraft75(const GURL& url, |
| 30 const std::string& origin, |
| 31 const std::string& location, |
| 32 const std::string& protocol); |
| 33 virtual ~WebSocketHandshakeDraft75(); |
| 34 |
| 35 // Creates the client handshake message from |this|. |
| 36 virtual std::string CreateClientHandshakeMessage(); |
| 37 |
| 38 // Reads server handshake message in |len| of |data|, updates |mode_| and |
| 39 // returns number of bytes of the server handshake message. |
| 40 // Once connection is established, |mode_| will be MODE_CONNECTED. |
| 41 // If connection establishment failed, |mode_| will be MODE_FAILED. |
| 42 // Returns negative if the server handshake message is incomplete. |
| 43 virtual int ReadServerHandshake(const char* data, size_t len); |
| 44 |
| 45 private: |
| 46 // Processes server handshake message, parsed as |headers|, and updates |
| 47 // |ws_origin_|, |ws_location_| and |ws_protocol_|. |
| 48 // Returns true if it's ok. |
| 49 // Returns false otherwise (e.g. duplicate WebSocket-Origin: header, etc.) |
| 50 virtual bool ProcessHeaders(const HttpResponseHeaders& headers); |
| 51 |
| 52 // Checks |ws_origin_|, |ws_location_| and |ws_protocol_| are valid |
| 53 // against |origin_|, |location_| and |protocol_|. |
| 54 // Returns true if it's ok. |
| 55 // Returns false otherwise (e.g. origin mismatch, etc.) |
| 56 virtual bool CheckResponseHeaders() const; |
| 57 |
| 58 DISALLOW_COPY_AND_ASSIGN(WebSocketHandshakeDraft75); |
| 59 }; |
| 60 |
| 61 } // namespace net |
| 62 |
| 63 #endif // NET_WEBSOCKETS_WEBSOCKET_HANDSHAKE_DRAFT75_H_ |
OLD | NEW |