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

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

Issue 2743003: Add Spdy support in WebSocketHandshake*Handler (Closed)
Patch Set: fix Created 10 years, 5 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
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 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 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
11 // browser process. 11 // browser process.
12 12
13 #ifndef NET_WEBSOCKETS_WEBSOCKET_HANDSHAKE_HANDLER_H_ 13 #ifndef NET_WEBSOCKETS_WEBSOCKET_HANDSHAKE_HANDLER_H_
14 #define NET_WEBSOCKETS_WEBSOCKET_HANDSHAKE_HANDLER_H_ 14 #define NET_WEBSOCKETS_WEBSOCKET_HANDSHAKE_HANDLER_H_
15 15
16 #include <string> 16 #include <string>
17 #include <vector> 17 #include <vector>
18 18
19 #include "base/ref_counted.h" 19 #include "base/ref_counted.h"
20 #include "net/http/http_request_info.h" 20 #include "net/http/http_request_info.h"
21 #include "net/http/http_response_info.h" 21 #include "net/http/http_response_info.h"
22 #include "net/spdy/spdy_framer.h"
22 23
23 namespace net { 24 namespace net {
24 25
25 class WebSocketHandshakeRequestHandler { 26 class WebSocketHandshakeRequestHandler {
26 public: 27 public:
27 WebSocketHandshakeRequestHandler(); 28 WebSocketHandshakeRequestHandler();
28 ~WebSocketHandshakeRequestHandler() {} 29 ~WebSocketHandshakeRequestHandler() {}
29 30
30 // Parses WebSocket handshake request from renderer process. 31 // Parses WebSocket handshake request from renderer process.
31 // It assumes a WebSocket handshake request message is given at once, and 32 // It assumes a WebSocket handshake request message is given at once, and
32 // no other data is added to the request message. 33 // no other data is added to the request message.
33 bool ParseRequest(const char* data, int length); 34 bool ParseRequest(const char* data, int length);
34 35
35 size_t original_length() const; 36 size_t original_length() const;
36 37
37 // Appends the header value pair for |name| and |value|, if |name| doesn't 38 // Appends the header value pair for |name| and |value|, if |name| doesn't
38 // exist. 39 // exist.
39 void AppendHeaderIfMissing(const std::string& name, 40 void AppendHeaderIfMissing(const std::string& name,
40 const std::string& value); 41 const std::string& value);
41 // Removes the headers that matches (case insensitive). 42 // Removes the headers that matches (case insensitive).
42 void RemoveHeaders(const char* const headers_to_remove[], 43 void RemoveHeaders(const char* const headers_to_remove[],
43 size_t headers_to_remove_len); 44 size_t headers_to_remove_len);
44 45
45 // Gets request info to open WebSocket connection. 46 // Gets request info to open WebSocket connection.
46 // Also, full challange data in |challenge|. 47 // Also, fill challange data in |challenge|.
47 HttpRequestInfo GetRequestInfo(const GURL& url, std::string* challenge); 48 HttpRequestInfo GetRequestInfo(const GURL& url, std::string* challenge);
49 // Gets request as SpdyHeaderBlock.
50 // Also, fill challenge data in |challenge|.
51 bool GetRequestHeaderBlock(const GURL& url,
52 spdy::SpdyHeaderBlock* headers,
53 std::string* challenge);
48 // Gets WebSocket handshake raw request message to open WebSocket 54 // Gets WebSocket handshake raw request message to open WebSocket
49 // connection. 55 // connection.
50 std::string GetRawRequest(); 56 std::string GetRawRequest();
51 // Calling raw_length is valid only after GetRawRquest() call. 57 // Calling raw_length is valid only after GetRawRquest() call.
52 size_t raw_length() const; 58 size_t raw_length() const;
53 59
54 private: 60 private:
55 std::string status_line_; 61 std::string status_line_;
56 std::string headers_; 62 std::string headers_;
57 std::string key3_; 63 std::string key3_;
(...skipping 14 matching lines...) Expand all
72 // handshake response message, returns zero. In other words, 78 // handshake response message, returns zero. In other words,
73 // [data + returned value, data + length) will be WebSocket frame data 79 // [data + returned value, data + length) will be WebSocket frame data
74 // after handshake response message. 80 // after handshake response message.
75 // TODO(ukai): fail fast when response gives wrong status code. 81 // TODO(ukai): fail fast when response gives wrong status code.
76 size_t ParseRawResponse(const char* data, int length); 82 size_t ParseRawResponse(const char* data, int length);
77 // Returns true if it already parses full handshake response message. 83 // Returns true if it already parses full handshake response message.
78 bool HasResponse() const; 84 bool HasResponse() const;
79 // Parses WebSocket handshake response info given as HttpResponseInfo. 85 // Parses WebSocket handshake response info given as HttpResponseInfo.
80 bool ParseResponseInfo(const HttpResponseInfo& response_info, 86 bool ParseResponseInfo(const HttpResponseInfo& response_info,
81 const std::string& challenge); 87 const std::string& challenge);
88 // Parses WebSocket handshake response as SpdyHeaderBlock.
89 bool ParseResponseHeaderBlock(const spdy::SpdyHeaderBlock& headers,
90 const std::string& challenge);
82 91
83 // Gets the headers value. 92 // Gets the headers value.
84 void GetHeaders(const char* const headers_to_get[], 93 void GetHeaders(const char* const headers_to_get[],
85 size_t headers_to_get_len, 94 size_t headers_to_get_len,
86 std::vector<std::string>* values); 95 std::vector<std::string>* values);
87 // Removes the headers that matches (case insensitive). 96 // Removes the headers that matches (case insensitive).
88 void RemoveHeaders(const char* const headers_to_remove[], 97 void RemoveHeaders(const char* const headers_to_remove[],
89 size_t headers_to_remove_len); 98 size_t headers_to_remove_len);
90 99
91 // Gets WebSocket handshake response message sent to renderer process. 100 // Gets WebSocket handshake response message sent to renderer process.
92 std::string GetResponse(); 101 std::string GetResponse();
93 102
94 private: 103 private:
95 std::string original_; 104 std::string original_;
96 int original_header_length_; 105 int original_header_length_;
97 std::string status_line_; 106 std::string status_line_;
98 std::string headers_; 107 std::string headers_;
99 std::string key_; 108 std::string key_;
100 109
101 DISALLOW_COPY_AND_ASSIGN(WebSocketHandshakeResponseHandler); 110 DISALLOW_COPY_AND_ASSIGN(WebSocketHandshakeResponseHandler);
102 }; 111 };
103 112
104 } // namespace net 113 } // namespace net
105 114
106 #endif // NET_WEBSOCKETS_WEBSOCKET_HANDSHAKE_HANDLER_H_ 115 #endif // NET_WEBSOCKETS_WEBSOCKET_HANDSHAKE_HANDLER_H_
OLDNEW
« no previous file with comments | « no previous file | net/websockets/websocket_handshake_handler.cc » ('j') | net/websockets/websocket_handshake_handler_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698