| Index: net/http/http_request_headers.cc
|
| ===================================================================
|
| --- net/http/http_request_headers.cc (revision 141317)
|
| +++ net/http/http_request_headers.cc (working copy)
|
| @@ -8,6 +8,7 @@
|
| #include "base/stringprintf.h"
|
| #include "base/string_split.h"
|
| #include "base/string_util.h"
|
| +#include "base/values.h"
|
| #include "net/http/http_util.h"
|
|
|
| namespace net {
|
| @@ -182,6 +183,54 @@
|
| return output;
|
| }
|
|
|
| +Value* HttpRequestHeaders::NetLogCallback(
|
| + const std::string* request_line,
|
| + NetLog::LogLevel /* log_level */) const {
|
| + DictionaryValue* dict = new DictionaryValue();
|
| + dict->SetString("line", *request_line);
|
| + ListValue* headers = new ListValue();
|
| + for (HeaderVector::const_iterator it = headers_.begin();
|
| + it != headers_.end(); ++it) {
|
| + headers->Append(
|
| + new StringValue(base::StringPrintf("%s: %s",
|
| + it->key.c_str(),
|
| + it->value.c_str())));
|
| + }
|
| + dict->Set("headers", headers);
|
| + return dict;
|
| +}
|
| +
|
| +// static
|
| +bool HttpRequestHeaders::FromNetLogParam(const base::Value* event_param,
|
| + HttpRequestHeaders* headers,
|
| + std::string* request_line) {
|
| + headers->Clear();
|
| + *request_line = "";
|
| +
|
| + const base::DictionaryValue* dict;
|
| + base::ListValue* header_list;
|
| +
|
| + if (!event_param ||
|
| + !event_param->GetAsDictionary(&dict) ||
|
| + !dict->GetList("headers", &header_list) ||
|
| + !dict->GetString("line", request_line)) {
|
| + return false;
|
| + }
|
| +
|
| + for (base::ListValue::const_iterator it = header_list->begin();
|
| + it != header_list->end();
|
| + ++it) {
|
| + std::string header_line;
|
| + if (!(*it)->GetAsString(&header_line)) {
|
| + headers->Clear();
|
| + *request_line = "";
|
| + return false;
|
| + }
|
| + headers->AddHeaderFromString(header_line);
|
| + }
|
| + return true;
|
| +}
|
| +
|
| HttpRequestHeaders::HeaderVector::iterator
|
| HttpRequestHeaders::FindHeader(const base::StringPiece& key) {
|
| for (HeaderVector::iterator it = headers_.begin();
|
|
|