| OLD | NEW |
| 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 |
| 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 "net/base/net_export.h" | 19 #include "net/base/net_export.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_header_block.h" | 22 #include "net/spdy/spdy_header_block.h" |
| 23 | 23 |
| 24 namespace net { | 24 namespace net { |
| 25 | 25 |
| 26 void ComputeSecWebSocketAccept(const std::string& key, | 26 void ComputeSecWebSocketAccept(const std::string& key, std::string* accept); |
| 27 std::string* accept); | |
| 28 | 27 |
| 29 class NET_EXPORT_PRIVATE WebSocketHandshakeRequestHandler { | 28 class NET_EXPORT_PRIVATE WebSocketHandshakeRequestHandler { |
| 30 public: | 29 public: |
| 31 WebSocketHandshakeRequestHandler(); | 30 WebSocketHandshakeRequestHandler(); |
| 32 ~WebSocketHandshakeRequestHandler() {} | 31 ~WebSocketHandshakeRequestHandler() {} |
| 33 | 32 |
| 34 // Parses WebSocket handshake request from renderer process. | 33 // Parses WebSocket handshake request from renderer process. |
| 35 // It assumes a WebSocket handshake request message is given at once, and | 34 // It assumes a WebSocket handshake request message is given at once, and |
| 36 // no other data is added to the request message. | 35 // no other data is added to the request message. |
| 37 bool ParseRequest(const char* data, int length); | 36 bool ParseRequest(const char* data, int length); |
| 38 | 37 |
| 39 size_t original_length() const; | 38 size_t original_length() const; |
| 40 | 39 |
| 41 // Appends the header value pair for |name| and |value|, if |name| doesn't | 40 // Appends the header value pair for |name| and |value|, if |name| doesn't |
| 42 // exist. | 41 // exist. |
| 43 void AppendHeaderIfMissing(const std::string& name, | 42 void AppendHeaderIfMissing(const std::string& name, const std::string& value); |
| 44 const std::string& value); | |
| 45 // Removes the headers that matches (case insensitive). | 43 // Removes the headers that matches (case insensitive). |
| 46 void RemoveHeaders(const char* const headers_to_remove[], | 44 void RemoveHeaders(const char* const headers_to_remove[], |
| 47 size_t headers_to_remove_len); | 45 size_t headers_to_remove_len); |
| 48 | 46 |
| 49 // Gets request info to open WebSocket connection and fills challenge data in | 47 // Gets request info to open WebSocket connection and fills challenge data in |
| 50 // |challenge|. | 48 // |challenge|. |
| 51 HttpRequestInfo GetRequestInfo(const GURL& url, std::string* challenge); | 49 HttpRequestInfo GetRequestInfo(const GURL& url, std::string* challenge); |
| 52 // Gets request as SpdyHeaderBlock. | 50 // Gets request as SpdyHeaderBlock. |
| 53 // Also, fills challenge data in |challenge|. | 51 // Also, fills challenge data in |challenge|. |
| 54 bool GetRequestHeaderBlock(const GURL& url, | 52 bool GetRequestHeaderBlock(const GURL& url, |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 std::string status_line_; | 113 std::string status_line_; |
| 116 std::string headers_; | 114 std::string headers_; |
| 117 std::string header_separator_; | 115 std::string header_separator_; |
| 118 | 116 |
| 119 DISALLOW_COPY_AND_ASSIGN(WebSocketHandshakeResponseHandler); | 117 DISALLOW_COPY_AND_ASSIGN(WebSocketHandshakeResponseHandler); |
| 120 }; | 118 }; |
| 121 | 119 |
| 122 } // namespace net | 120 } // namespace net |
| 123 | 121 |
| 124 #endif // NET_WEBSOCKETS_WEBSOCKET_HANDSHAKE_HANDLER_H_ | 122 #endif // NET_WEBSOCKETS_WEBSOCKET_HANDSHAKE_HANDLER_H_ |
| OLD | NEW |