OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/url_request/url_request.h" | 5 #include "net/url_request/url_request.h" |
6 | 6 |
7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
8 #include "base/process_util.h" | 8 #include "base/process_util.h" |
9 #include "base/singleton.h" | 9 #include "base/singleton.h" |
10 #include "base/stats_counters.h" | 10 #include "base/stats_counters.h" |
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
344 } | 344 } |
345 | 345 |
346 // static | 346 // static |
347 std::string URLRequest::StripPostSpecificHeaders(const std::string& headers) { | 347 std::string URLRequest::StripPostSpecificHeaders(const std::string& headers) { |
348 // These are headers that may be attached to a POST. | 348 // These are headers that may be attached to a POST. |
349 static const char* const kPostHeaders[] = { | 349 static const char* const kPostHeaders[] = { |
350 "content-type", | 350 "content-type", |
351 "content-length", | 351 "content-length", |
352 "origin" | 352 "origin" |
353 }; | 353 }; |
354 | 354 return net::HttpUtil::StripHeaders( |
355 std::string stripped_headers; | 355 headers, kPostHeaders, arraysize(kPostHeaders)); |
356 net::HttpUtil::HeadersIterator it(headers.begin(), headers.end(), "\r\n"); | |
357 | |
358 while (it.GetNext()) { | |
359 bool is_post_specific = false; | |
360 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kPostHeaders); ++i) { | |
361 if (LowerCaseEqualsASCII(it.name_begin(), it.name_end(), | |
362 kPostHeaders[i])) { | |
363 is_post_specific = true; | |
364 break; | |
365 } | |
366 } | |
367 if (!is_post_specific) { | |
368 // Assume that name and values are on the same line. | |
369 stripped_headers.append(it.name_begin(), it.values_end()); | |
370 stripped_headers.append("\r\n"); | |
371 } | |
372 } | |
373 return stripped_headers; | |
374 } | 356 } |
375 | 357 |
376 int URLRequest::Redirect(const GURL& location, int http_status_code) { | 358 int URLRequest::Redirect(const GURL& location, int http_status_code) { |
377 if (redirect_limit_ <= 0) { | 359 if (redirect_limit_ <= 0) { |
378 DLOG(INFO) << "disallowing redirect: exceeds limit"; | 360 DLOG(INFO) << "disallowing redirect: exceeds limit"; |
379 return net::ERR_TOO_MANY_REDIRECTS; | 361 return net::ERR_TOO_MANY_REDIRECTS; |
380 } | 362 } |
381 | 363 |
382 if (!job_->IsSafeRedirect(location)) { | 364 if (!job_->IsSafeRedirect(location)) { |
383 DLOG(INFO) << "disallowing redirect: unsafe protocol"; | 365 DLOG(INFO) << "disallowing redirect: unsafe protocol"; |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
440 } | 422 } |
441 | 423 |
442 #ifndef NDEBUG | 424 #ifndef NDEBUG |
443 | 425 |
444 URLRequestMetrics::~URLRequestMetrics() { | 426 URLRequestMetrics::~URLRequestMetrics() { |
445 DLOG_IF(WARNING, object_count != 0) << | 427 DLOG_IF(WARNING, object_count != 0) << |
446 "Leaking " << object_count << " URLRequest object(s)"; | 428 "Leaking " << object_count << " URLRequest object(s)"; |
447 } | 429 } |
448 | 430 |
449 #endif | 431 #endif |
OLD | NEW |