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

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

Issue 723343002: Update from https://crrev.com/304121 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years, 1 month 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "net/websockets/websocket_net_log_params.h"
6
7 #include "base/strings/stringprintf.h"
8 #include "base/values.h"
9
10 namespace net {
11
12 base::Value* NetLogWebSocketHandshakeCallback(
13 const std::string* headers,
14 NetLog::LogLevel /* log_level */) {
15 base::DictionaryValue* dict = new base::DictionaryValue();
16 base::ListValue* header_list = new base::ListValue();
17
18 size_t last = 0;
19 size_t headers_size = headers->size();
20 size_t pos = 0;
21 while (pos <= headers_size) {
22 if (pos == headers_size ||
23 ((*headers)[pos] == '\r' &&
24 pos + 1 < headers_size && (*headers)[pos + 1] == '\n')) {
25 std::string entry = headers->substr(last, pos - last);
26 pos += 2;
27 last = pos;
28
29 header_list->Append(new base::StringValue(entry));
30
31 if (entry.empty()) {
32 // Dump WebSocket key3.
33 std::string key;
34 for (; pos < headers_size; ++pos) {
35 key += base::StringPrintf("\\x%02x", (*headers)[pos] & 0xff);
36 }
37 header_list->Append(new base::StringValue(key));
38 break;
39 }
40 } else {
41 ++pos;
42 }
43 }
44
45 dict->Set("headers", header_list);
46 return dict;
47 }
48
49 } // namespace net
OLDNEW
« no previous file with comments | « net/websockets/websocket_net_log_params.h ('k') | net/websockets/websocket_net_log_params_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698