| 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 // The rules for parsing content-types were borrowed from Firefox: | 5 // The rules for parsing content-types were borrowed from Firefox: |
| 6 // http://lxr.mozilla.org/mozilla/source/netwerk/base/src/nsURLHelper.cpp#834 | 6 // http://lxr.mozilla.org/mozilla/source/netwerk/base/src/nsURLHelper.cpp#834 |
| 7 | 7 |
| 8 #include "net/http/http_util.h" | 8 #include "net/http/http_util.h" |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| 11 | 11 |
| 12 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 #include "base/stl_util.h" |
| 13 #include "base/strings/string_number_conversions.h" | 14 #include "base/strings/string_number_conversions.h" |
| 14 #include "base/strings/string_piece.h" | 15 #include "base/strings/string_piece.h" |
| 15 #include "base/strings/string_tokenizer.h" | 16 #include "base/strings/string_tokenizer.h" |
| 16 #include "base/strings/string_util.h" | 17 #include "base/strings/string_util.h" |
| 17 #include "base/strings/stringprintf.h" | 18 #include "base/strings/stringprintf.h" |
| 18 #include "base/time/time.h" | 19 #include "base/time/time.h" |
| 19 #include "net/base/url_util.h" | 20 #include "net/base/url_util.h" |
| 20 | 21 |
| 21 namespace net { | 22 namespace net { |
| 22 | 23 |
| (...skipping 677 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 700 // Check if the current line can be continued. | 701 // Check if the current line can be continued. |
| 701 prev_line_continuable = IsLineSegmentContinuable(line_begin, line_end); | 702 prev_line_continuable = IsLineSegmentContinuable(line_begin, line_end); |
| 702 } | 703 } |
| 703 } | 704 } |
| 704 | 705 |
| 705 raw_headers.append("\n\n", 2); | 706 raw_headers.append("\n\n", 2); |
| 706 | 707 |
| 707 // Use '\0' as the canonical line terminator. If the input already contained | 708 // Use '\0' as the canonical line terminator. If the input already contained |
| 708 // any embeded '\0' characters we will strip them first to avoid interpreting | 709 // any embeded '\0' characters we will strip them first to avoid interpreting |
| 709 // them as line breaks. | 710 // them as line breaks. |
| 710 raw_headers.erase(std::remove(raw_headers.begin(), raw_headers.end(), '\0'), | 711 base::Erase(raw_headers, '\0'); |
| 711 raw_headers.end()); | 712 |
| 712 std::replace(raw_headers.begin(), raw_headers.end(), '\n', '\0'); | 713 std::replace(raw_headers.begin(), raw_headers.end(), '\n', '\0'); |
| 713 | 714 |
| 714 return raw_headers; | 715 return raw_headers; |
| 715 } | 716 } |
| 716 | 717 |
| 717 std::string HttpUtil::ConvertHeadersBackToHTTPResponse(const std::string& str) { | 718 std::string HttpUtil::ConvertHeadersBackToHTTPResponse(const std::string& str) { |
| 718 std::string disassembled_headers; | 719 std::string disassembled_headers; |
| 719 base::StringTokenizer tokenizer(str, std::string(1, '\0')); | 720 base::StringTokenizer tokenizer(str, std::string(1, '\0')); |
| 720 while (tokenizer.GetNext()) { | 721 while (tokenizer.GetNext()) { |
| 721 disassembled_headers.append(tokenizer.token_begin(), tokenizer.token_end()); | 722 disassembled_headers.append(tokenizer.token_begin(), tokenizer.token_end()); |
| (...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1042 return true; | 1043 return true; |
| 1043 } | 1044 } |
| 1044 | 1045 |
| 1045 bool HttpUtil::NameValuePairsIterator::IsQuote(char c) const { | 1046 bool HttpUtil::NameValuePairsIterator::IsQuote(char c) const { |
| 1046 if (strict_quotes_) | 1047 if (strict_quotes_) |
| 1047 return c == '"'; | 1048 return c == '"'; |
| 1048 return HttpUtil::IsQuote(c); | 1049 return HttpUtil::IsQuote(c); |
| 1049 } | 1050 } |
| 1050 | 1051 |
| 1051 } // namespace net | 1052 } // namespace net |
| OLD | NEW |