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

Side by Side Diff: net/websockets/websocket_handshake_handler.h

Issue 10843050: WebSocket over SPDY: handshake support for both of SPDY/2 and SPDY/3 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: move spdy related tests to new files Created 8 years, 4 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 // WebSocketHandshake*Handler handles WebSocket handshake request message 5 // WebSocketHandshake*Handler handles WebSocket handshake request message
6 // from WebKit renderer process, and WebSocket handshake response message 6 // from WebKit renderer process, and WebSocket handshake response message
7 // from WebSocket server. 7 // from WebSocket server.
8 // It modifies messages for the following reason: 8 // It modifies messages for the following reason:
9 // - We don't trust WebKit renderer process, so we'll not expose HttpOnly 9 // - We don't trust WebKit renderer process, so we'll not expose HttpOnly
10 // cookies to the renderer process, so handles HttpOnly cookies in 10 // cookies to the renderer process, so handles HttpOnly cookies in
(...skipping 17 matching lines...) Expand all
28 #ifndef NET_WEBSOCKETS_WEBSOCKET_HANDSHAKE_HANDLER_H_ 28 #ifndef NET_WEBSOCKETS_WEBSOCKET_HANDSHAKE_HANDLER_H_
29 #define NET_WEBSOCKETS_WEBSOCKET_HANDSHAKE_HANDLER_H_ 29 #define NET_WEBSOCKETS_WEBSOCKET_HANDSHAKE_HANDLER_H_
30 30
31 #include <string> 31 #include <string>
32 #include <vector> 32 #include <vector>
33 33
34 #include "base/memory/ref_counted.h" 34 #include "base/memory/ref_counted.h"
35 #include "net/base/net_export.h" 35 #include "net/base/net_export.h"
36 #include "net/http/http_request_info.h" 36 #include "net/http/http_request_info.h"
37 #include "net/http/http_response_info.h" 37 #include "net/http/http_response_info.h"
38 #include "net/socket/next_proto.h"
38 #include "net/spdy/spdy_framer.h" 39 #include "net/spdy/spdy_framer.h"
39 40
40 namespace net { 41 namespace net {
41 42
42 class NET_EXPORT_PRIVATE WebSocketHandshakeRequestHandler { 43 class NET_EXPORT_PRIVATE WebSocketHandshakeRequestHandler {
43 public: 44 public:
44 WebSocketHandshakeRequestHandler(); 45 WebSocketHandshakeRequestHandler();
45 ~WebSocketHandshakeRequestHandler() {} 46 ~WebSocketHandshakeRequestHandler() {}
46 47
47 // Parses WebSocket handshake request from renderer process. 48 // Parses WebSocket handshake request from renderer process.
(...skipping 13 matching lines...) Expand all
61 62
62 // Gets request info to open WebSocket connection. 63 // Gets request info to open WebSocket connection.
63 // Fills challange data (concatenation of key1, 2 and 3 for hybi-03 and 64 // Fills challange data (concatenation of key1, 2 and 3 for hybi-03 and
64 // earlier, or Sec-WebSocket-Key header value for hybi-04 and later) 65 // earlier, or Sec-WebSocket-Key header value for hybi-04 and later)
65 // in |challenge|. 66 // in |challenge|.
66 HttpRequestInfo GetRequestInfo(const GURL& url, std::string* challenge); 67 HttpRequestInfo GetRequestInfo(const GURL& url, std::string* challenge);
67 // Gets request as SpdyHeaderBlock. 68 // Gets request as SpdyHeaderBlock.
68 // Also, fills challenge data in |challenge|. 69 // Also, fills challenge data in |challenge|.
69 bool GetRequestHeaderBlock(const GURL& url, 70 bool GetRequestHeaderBlock(const GURL& url,
70 SpdyHeaderBlock* headers, 71 SpdyHeaderBlock* headers,
71 std::string* challenge); 72 std::string* challenge,
73 NextProto protocol_negotiated);
72 // Gets WebSocket handshake raw request message to open WebSocket 74 // Gets WebSocket handshake raw request message to open WebSocket
73 // connection. 75 // connection.
74 std::string GetRawRequest(); 76 std::string GetRawRequest();
75 // Calling raw_length is valid only after GetRawRquest() call. 77 // Calling raw_length is valid only after GetRawRquest() call.
76 size_t raw_length() const; 78 size_t raw_length() const;
77 79
78 // Returns the value of Sec-WebSocket-Version or Sec-WebSocket-Draft header 80 // Returns the value of Sec-WebSocket-Version or Sec-WebSocket-Draft header
79 // (the latter is an old name of the former). Returns 0 if both headers were 81 // (the latter is an old name of the former). Returns 0 if both headers were
80 // absent, which means the handshake was based on hybi-00 (= hixie-76). 82 // absent, which means the handshake was based on hybi-00 (= hixie-76).
81 // Should only be called after the handshake has been parsed. 83 // Should only be called after the handshake has been parsed.
(...skipping 28 matching lines...) Expand all
110 // after handshake response message. 112 // after handshake response message.
111 // TODO(ukai): fail fast when response gives wrong status code. 113 // TODO(ukai): fail fast when response gives wrong status code.
112 size_t ParseRawResponse(const char* data, int length); 114 size_t ParseRawResponse(const char* data, int length);
113 // Returns true if it already parses full handshake response message. 115 // Returns true if it already parses full handshake response message.
114 bool HasResponse() const; 116 bool HasResponse() const;
115 // Parses WebSocket handshake response info given as HttpResponseInfo. 117 // Parses WebSocket handshake response info given as HttpResponseInfo.
116 bool ParseResponseInfo(const HttpResponseInfo& response_info, 118 bool ParseResponseInfo(const HttpResponseInfo& response_info,
117 const std::string& challenge); 119 const std::string& challenge);
118 // Parses WebSocket handshake response as SpdyHeaderBlock. 120 // Parses WebSocket handshake response as SpdyHeaderBlock.
119 bool ParseResponseHeaderBlock(const SpdyHeaderBlock& headers, 121 bool ParseResponseHeaderBlock(const SpdyHeaderBlock& headers,
120 const std::string& challenge); 122 const std::string& challenge,
123 NextProto protocol_negotiated);
121 124
122 // Gets the headers value. 125 // Gets the headers value.
123 void GetHeaders(const char* const headers_to_get[], 126 void GetHeaders(const char* const headers_to_get[],
124 size_t headers_to_get_len, 127 size_t headers_to_get_len,
125 std::vector<std::string>* values); 128 std::vector<std::string>* values);
126 // Removes the headers that matches (case insensitive). 129 // Removes the headers that matches (case insensitive).
127 void RemoveHeaders(const char* const headers_to_remove[], 130 void RemoveHeaders(const char* const headers_to_remove[],
128 size_t headers_to_remove_len); 131 size_t headers_to_remove_len);
129 132
130 // Gets raw WebSocket handshake response received from WebSocket server. 133 // Gets raw WebSocket handshake response received from WebSocket server.
(...skipping 15 matching lines...) Expand all
146 std::string header_separator_; 149 std::string header_separator_;
147 std::string key_; 150 std::string key_;
148 int protocol_version_; 151 int protocol_version_;
149 152
150 DISALLOW_COPY_AND_ASSIGN(WebSocketHandshakeResponseHandler); 153 DISALLOW_COPY_AND_ASSIGN(WebSocketHandshakeResponseHandler);
151 }; 154 };
152 155
153 } // namespace net 156 } // namespace net
154 157
155 #endif // NET_WEBSOCKETS_WEBSOCKET_HANDSHAKE_HANDLER_H_ 158 #endif // NET_WEBSOCKETS_WEBSOCKET_HANDSHAKE_HANDLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698