| OLD | NEW |
| 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/http/http_request_headers.h" | 5 #include "net/http/http_request_headers.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/strings/string_split.h" | 8 #include "base/strings/string_split.h" |
| 9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
| 10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 base::StringAppendF(&output, "%s: %s\r\n", | 181 base::StringAppendF(&output, "%s: %s\r\n", |
| 182 it->key.c_str(), it->value.c_str()); | 182 it->key.c_str(), it->value.c_str()); |
| 183 } else { | 183 } else { |
| 184 base::StringAppendF(&output, "%s:\r\n", it->key.c_str()); | 184 base::StringAppendF(&output, "%s:\r\n", it->key.c_str()); |
| 185 } | 185 } |
| 186 } | 186 } |
| 187 output.append("\r\n"); | 187 output.append("\r\n"); |
| 188 return output; | 188 return output; |
| 189 } | 189 } |
| 190 | 190 |
| 191 base::Value* HttpRequestHeaders::NetLogCallback( | 191 scoped_ptr<base::Value> HttpRequestHeaders::NetLogCallback( |
| 192 const std::string* request_line, | 192 const std::string* request_line, |
| 193 NetLogCaptureMode capture_mode) const { | 193 NetLogCaptureMode capture_mode) const { |
| 194 base::DictionaryValue* dict = new base::DictionaryValue(); | 194 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); |
| 195 dict->SetString("line", *request_line); | 195 dict->SetString("line", *request_line); |
| 196 base::ListValue* headers = new base::ListValue(); | 196 scoped_ptr<base::ListValue> headers(new base::ListValue()); |
| 197 for (HeaderVector::const_iterator it = headers_.begin(); | 197 for (HeaderVector::const_iterator it = headers_.begin(); |
| 198 it != headers_.end(); ++it) { | 198 it != headers_.end(); ++it) { |
| 199 std::string log_value = | 199 std::string log_value = |
| 200 ElideHeaderValueForNetLog(capture_mode, it->key, it->value); | 200 ElideHeaderValueForNetLog(capture_mode, it->key, it->value); |
| 201 headers->Append(new base::StringValue( | 201 headers->Append(new base::StringValue( |
| 202 base::StringPrintf("%s: %s", | 202 base::StringPrintf("%s: %s", |
| 203 it->key.c_str(), log_value.c_str()))); | 203 it->key.c_str(), log_value.c_str()))); |
| 204 } | 204 } |
| 205 dict->Set("headers", headers); | 205 dict->Set("headers", headers.Pass()); |
| 206 return dict; | 206 return dict.Pass(); |
| 207 } | 207 } |
| 208 | 208 |
| 209 // static | 209 // static |
| 210 bool HttpRequestHeaders::FromNetLogParam(const base::Value* event_param, | 210 bool HttpRequestHeaders::FromNetLogParam(const base::Value* event_param, |
| 211 HttpRequestHeaders* headers, | 211 HttpRequestHeaders* headers, |
| 212 std::string* request_line) { | 212 std::string* request_line) { |
| 213 headers->Clear(); | 213 headers->Clear(); |
| 214 *request_line = ""; | 214 *request_line = ""; |
| 215 | 215 |
| 216 const base::DictionaryValue* dict = NULL; | 216 const base::DictionaryValue* dict = NULL; |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 255 it != headers_.end(); ++it) { | 255 it != headers_.end(); ++it) { |
| 256 if (key.length() == it->key.length() && | 256 if (key.length() == it->key.length() && |
| 257 !base::strncasecmp(key.data(), it->key.data(), key.length())) | 257 !base::strncasecmp(key.data(), it->key.data(), key.length())) |
| 258 return it; | 258 return it; |
| 259 } | 259 } |
| 260 | 260 |
| 261 return headers_.end(); | 261 return headers_.end(); |
| 262 } | 262 } |
| 263 | 263 |
| 264 } // namespace net | 264 } // namespace net |
| OLD | NEW |