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

Unified Diff: net/websockets/websocket_handshake_handler.cc

Issue 48733008: Factor out Sec-WebSocket-Accept computing logic so that the new WebSocket handshake processor can r… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 2 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_handler.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/websockets/websocket_handshake_handler.cc
diff --git a/net/websockets/websocket_handshake_handler.cc b/net/websockets/websocket_handshake_handler.cc
index 0fd67f9691ba69503e4b9db33acd6f94cb7319fb..641b196806e85a4fd465845bd45f8f457321ac86 100644
--- a/net/websockets/websocket_handshake_handler.cc
+++ b/net/websockets/websocket_handshake_handler.cc
@@ -345,6 +345,16 @@ bool WebSocketHandshakeResponseHandler::HasResponse() const {
static_cast<size_t>(original_header_length_) <= original_.size();
}
+void ComputeSecWebSocketAccept(const std::string& key,
+ std::string* accept) {
+ DCHECK(accept);
+
+ std::string hash =
+ base::SHA1HashString(key + websockets::kWebSocketGuid);
+ bool encode_success = base::Base64Encode(hash, accept);
+ DCHECK(encode_success);
+}
+
bool WebSocketHandshakeResponseHandler::ParseResponseInfo(
const HttpResponseInfo& response_info,
const std::string& challenge) {
@@ -363,11 +373,8 @@ bool WebSocketHandshakeResponseHandler::ParseResponseInfo(
AppendHeader(
HttpRequestHeaders::kConnection, websockets::kUpgrade, &response_message);
- std::string hash =
- base::SHA1HashString(challenge + websockets::kWebSocketGuid);
std::string websocket_accept;
- bool encode_success = base::Base64Encode(hash, &websocket_accept);
- DCHECK(encode_success);
+ ComputeSecWebSocketAccept(challenge, &websocket_accept);
AppendHeader(
websockets::kSecWebSocketAccept, websocket_accept, &response_message);
« no previous file with comments | « net/websockets/websocket_handshake_handler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698