This source file includes following definitions.
- NetLogWebSocketHandshakeCallback
#include "net/websockets/websocket_net_log_params.h"
#include "base/strings/stringprintf.h"
#include "base/values.h"
namespace net {
base::Value* NetLogWebSocketHandshakeCallback(
const std::string* headers,
NetLog::LogLevel ) {
base::DictionaryValue* dict = new base::DictionaryValue();
base::ListValue* header_list = new base::ListValue();
size_t last = 0;
size_t headers_size = headers->size();
size_t pos = 0;
while (pos <= headers_size) {
if (pos == headers_size ||
((*headers)[pos] == '\r' &&
pos + 1 < headers_size && (*headers)[pos + 1] == '\n')) {
std::string entry = headers->substr(last, pos - last);
pos += 2;
last = pos;
header_list->Append(new base::StringValue(entry));
if (entry.empty()) {
std::string key;
for (; pos < headers_size; ++pos) {
key += base::StringPrintf("\\x%02x", (*headers)[pos] & 0xff);
}
header_list->Append(new base::StringValue(key));
break;
}
} else {
++pos;
}
}
dict->Set("headers", header_list);
return dict;
}
}