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

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

Issue 12087091: Move string tokenizer to base/strings. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 10 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 #include "net/websockets/websocket_handshake_handler.h" 5 #include "net/websockets/websocket_handshake_handler.h"
6 6
7 #include "base/base64.h" 7 #include "base/base64.h"
8 #include "base/md5.h" 8 #include "base/md5.h"
9 #include "base/sha1.h" 9 #include "base/sha1.h"
10 #include "base/string_number_conversions.h" 10 #include "base/string_number_conversions.h"
11 #include "base/string_piece.h" 11 #include "base/string_piece.h"
12 #include "base/string_util.h" 12 #include "base/string_util.h"
13 #include "base/stringprintf.h" 13 #include "base/stringprintf.h"
14 #include "base/strings/string_tokenizer.h"
14 #include "googleurl/src/gurl.h" 15 #include "googleurl/src/gurl.h"
15 #include "net/http/http_response_headers.h" 16 #include "net/http/http_response_headers.h"
16 #include "net/http/http_util.h" 17 #include "net/http/http_util.h"
17 18
18 namespace { 19 namespace {
19 20
20 const size_t kRequestKey3Size = 8U; 21 const size_t kRequestKey3Size = 8U;
21 const size_t kResponseKeySize = 16U; 22 const size_t kResponseKeySize = 16U;
22 23
23 // First version that introduced new WebSocket handshake which does not 24 // First version that introduced new WebSocket handshake which does not
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 } 83 }
83 84
84 // Similar to HttpUtil::StripHeaders, but it preserves malformed headers, that 85 // Similar to HttpUtil::StripHeaders, but it preserves malformed headers, that
85 // is, lines that are not formatted as "<name>: <value>\r\n". 86 // is, lines that are not formatted as "<name>: <value>\r\n".
86 std::string FilterHeaders( 87 std::string FilterHeaders(
87 const std::string& headers, 88 const std::string& headers,
88 const char* const headers_to_remove[], 89 const char* const headers_to_remove[],
89 size_t headers_to_remove_len) { 90 size_t headers_to_remove_len) {
90 std::string filtered_headers; 91 std::string filtered_headers;
91 92
92 StringTokenizer lines(headers.begin(), headers.end(), "\r\n"); 93 base::StringTokenizer lines(headers.begin(), headers.end(), "\r\n");
93 while (lines.GetNext()) { 94 while (lines.GetNext()) {
94 std::string::const_iterator line_begin = lines.token_begin(); 95 std::string::const_iterator line_begin = lines.token_begin();
95 std::string::const_iterator line_end = lines.token_end(); 96 std::string::const_iterator line_end = lines.token_end();
96 std::string::const_iterator name_begin; 97 std::string::const_iterator name_begin;
97 std::string::const_iterator name_end; 98 std::string::const_iterator name_end;
98 bool should_remove = false; 99 bool should_remove = false;
99 if (GetHeaderName(line_begin, line_end, &name_begin, &name_end)) { 100 if (GetHeaderName(line_begin, line_end, &name_begin, &name_end)) {
100 for (size_t i = 0; i < headers_to_remove_len; ++i) { 101 for (size_t i = 0; i < headers_to_remove_len; ++i) {
101 if (LowerCaseEqualsASCII(name_begin, name_end, headers_to_remove[i])) { 102 if (LowerCaseEqualsASCII(name_begin, name_end, headers_to_remove[i])) {
102 should_remove = true; 103 should_remove = true;
(...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after
556 return status_line_ + headers_ + header_separator_ + key_; 557 return status_line_ + headers_ + header_separator_ + key_;
557 } 558 }
558 559
559 size_t WebSocketHandshakeResponseHandler::GetResponseKeySize() const { 560 size_t WebSocketHandshakeResponseHandler::GetResponseKeySize() const {
560 if (protocol_version_ >= kMinVersionOfHybiNewHandshake) 561 if (protocol_version_ >= kMinVersionOfHybiNewHandshake)
561 return 0; 562 return 0;
562 return kResponseKeySize; 563 return kResponseKeySize;
563 } 564 }
564 565
565 } // namespace net 566 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698