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

Unified Diff: net/websockets/websocket_handshake_draft75.h

Issue 1108002: Implement new websocket handshake based on draft-hixie-thewebsocketprotocol-76 (Closed)
Patch Set: fix for review comments Created 10 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/websockets/websocket_handshake.cc ('k') | net/websockets/websocket_handshake_draft75.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/websockets/websocket_handshake_draft75.h
diff --git a/net/websockets/websocket_handshake_draft75.h b/net/websockets/websocket_handshake_draft75.h
new file mode 100644
index 0000000000000000000000000000000000000000..6cc0506aa7a7ab26ddb56b81b42851cdf3c655b7
--- /dev/null
+++ b/net/websockets/websocket_handshake_draft75.h
@@ -0,0 +1,63 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef NET_WEBSOCKETS_WEBSOCKET_HANDSHAKE_DRAFT75_H_
+#define NET_WEBSOCKETS_WEBSOCKET_HANDSHAKE_DRAFT75_H_
+
+#include <string>
+
+#include "base/basictypes.h"
+#include "googleurl/src/gurl.h"
+#include "net/websockets/websocket_handshake.h"
+
+namespace net {
+
+class HttpResponseHeaders;
+
+class WebSocketHandshakeDraft75 : public WebSocketHandshake {
+ public:
+ static const int kWebSocketPort;
+ static const int kSecureWebSocketPort;
+ static const char kServerHandshakeHeader[];
+ static const size_t kServerHandshakeHeaderLength;
+ static const char kUpgradeHeader[];
+ static const size_t kUpgradeHeaderLength;
+ static const char kConnectionHeader[];
+ static const size_t kConnectionHeaderLength;
+
+ WebSocketHandshakeDraft75(const GURL& url,
+ const std::string& origin,
+ const std::string& location,
+ const std::string& protocol);
+ virtual ~WebSocketHandshakeDraft75();
+
+ // Creates the client handshake message from |this|.
+ virtual std::string CreateClientHandshakeMessage();
+
+ // Reads server handshake message in |len| of |data|, updates |mode_| and
+ // returns number of bytes of the server handshake message.
+ // Once connection is established, |mode_| will be MODE_CONNECTED.
+ // If connection establishment failed, |mode_| will be MODE_FAILED.
+ // Returns negative if the server handshake message is incomplete.
+ virtual int ReadServerHandshake(const char* data, size_t len);
+
+ private:
+ // Processes server handshake message, parsed as |headers|, and updates
+ // |ws_origin_|, |ws_location_| and |ws_protocol_|.
+ // Returns true if it's ok.
+ // Returns false otherwise (e.g. duplicate WebSocket-Origin: header, etc.)
+ virtual bool ProcessHeaders(const HttpResponseHeaders& headers);
+
+ // Checks |ws_origin_|, |ws_location_| and |ws_protocol_| are valid
+ // against |origin_|, |location_| and |protocol_|.
+ // Returns true if it's ok.
+ // Returns false otherwise (e.g. origin mismatch, etc.)
+ virtual bool CheckResponseHeaders() const;
+
+ DISALLOW_COPY_AND_ASSIGN(WebSocketHandshakeDraft75);
+};
+
+} // namespace net
+
+#endif // NET_WEBSOCKETS_WEBSOCKET_HANDSHAKE_DRAFT75_H_
« no previous file with comments | « net/websockets/websocket_handshake.cc ('k') | net/websockets/websocket_handshake_draft75.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698