Chromium Code Reviews| Index: net/http/http_request_headers.cc |
| =================================================================== |
| --- net/http/http_request_headers.cc (revision 140753) |
| +++ 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,55 @@ |
| 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; |
| +} |
| + |
| +bool HttpRequestHeaders::FromNetLogParam(const base::Value* event_param, |
| + HttpRequestHeaders* headers, |
| + std::string* request_line) { |
| + headers->Clear(); |
| + *request_line = ""; |
| + |
| + const base::DictionaryValue *dict; |
|
eroman
2012/06/06 21:27:11
nit: asterisk on left
mmenke
2012/06/07 19:20:46
Done.
|
| + // Not const because there's no overload of Dictionary::GetList that takes |
| + // a const list. |
| + base::ListValue *header_list; |
|
eroman
2012/06/06 21:27:11
nit: asterisk on left
mmenke
2012/06/07 19:20:46
Done.
|
| + |
| + 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(); |