| Index: net/http/http_util.cc
|
| diff --git a/net/http/http_util.cc b/net/http/http_util.cc
|
| index f4f994af6052f294bb52e1714cf1ca625af1cadc..59d335f94193dfc70a64ceb68b4b6ed16fc1ad0d 100644
|
| --- a/net/http/http_util.cc
|
| +++ b/net/http/http_util.cc
|
| @@ -18,7 +18,6 @@
|
| #include "base/strings/stringprintf.h"
|
| #include "base/time/time.h"
|
|
|
| -
|
| namespace net {
|
|
|
| // Helpers --------------------------------------------------------------------
|
| @@ -30,16 +29,16 @@ static size_t FindStringEnd(const std::string& line, size_t start, char delim) {
|
| DCHECK_EQ(line[start], delim);
|
| DCHECK((delim == '"') || (delim == '\''));
|
|
|
| - const char set[] = { delim, '\\', '\0' };
|
| + const char set[] = {delim, '\\', '\0'};
|
| for (size_t end = line.find_first_of(set, start + 1);
|
| - end != std::string::npos; end = line.find_first_of(set, end + 2)) {
|
| + end != std::string::npos;
|
| + end = line.find_first_of(set, end + 2)) {
|
| if (line[end] != '\\')
|
| return end;
|
| }
|
| return line.length();
|
| }
|
|
|
| -
|
| // HttpUtil -------------------------------------------------------------------
|
|
|
| // static
|
| @@ -49,7 +48,7 @@ size_t HttpUtil::FindDelimiter(const std::string& line,
|
| do {
|
| // search_start points to the spot from which we should start looking
|
| // for the delimiter.
|
| - const char delim_str[] = { delimiter, '"', '\'', '\0' };
|
| + const char delim_str[] = {delimiter, '"', '\'', '\0'};
|
| size_t cur_delim_pos = line.find_first_of(delim_str, search_start);
|
| if (cur_delim_pos == std::string::npos)
|
| return line.length();
|
| @@ -100,8 +99,8 @@ void HttpUtil::ParseContentType(const std::string& content_type_str,
|
| // Iterate over parameters
|
| size_t param_start = content_type_str.find_first_of(';', type_end);
|
| if (param_start != std::string::npos) {
|
| - base::StringTokenizer tokenizer(begin + param_start, content_type_str.end(),
|
| - ";");
|
| + base::StringTokenizer tokenizer(
|
| + begin + param_start, content_type_str.end(), ";");
|
| tokenizer.set_quote_chars("\"");
|
| while (tokenizer.GetNext()) {
|
| std::string::const_iterator equals_sign =
|
| @@ -123,8 +122,8 @@ void HttpUtil::ParseContentType(const std::string& content_type_str,
|
| charset_val = param_value_begin - begin;
|
| charset_end = param_value_end - begin;
|
| type_has_charset = true;
|
| - } else if (LowerCaseEqualsASCII(param_name_begin, param_name_end,
|
| - "boundary")) {
|
| + } else if (LowerCaseEqualsASCII(
|
| + param_name_begin, param_name_end, "boundary")) {
|
| if (boundary)
|
| boundary->assign(param_value_begin, param_value_end);
|
| }
|
| @@ -143,9 +142,9 @@ void HttpUtil::ParseContentType(const std::string& content_type_str,
|
| ++charset_val;
|
| DCHECK(charset_end >= charset_val);
|
| } else {
|
| - charset_end = std::min(content_type_str.find_first_of(HTTP_LWS ";(",
|
| - charset_val),
|
| - charset_end);
|
| + charset_end =
|
| + std::min(content_type_str.find_first_of(HTTP_LWS ";(", charset_val),
|
| + charset_end);
|
| }
|
| }
|
|
|
| @@ -156,13 +155,12 @@ void HttpUtil::ParseContentType(const std::string& content_type_str,
|
| // also want to reject a mime-type if it does not include a slash.
|
| // some servers give junk after the charset parameter, which may
|
| // include a comma, so this check makes us a bit more tolerant.
|
| - if (content_type_str.length() != 0 &&
|
| - content_type_str != "*/*" &&
|
| + if (content_type_str.length() != 0 && content_type_str != "*/*" &&
|
| content_type_str.find_first_of('/') != std::string::npos) {
|
| // Common case here is that mime_type is empty
|
| - bool eq = !mime_type->empty() && LowerCaseEqualsASCII(begin + type_val,
|
| - begin + type_end,
|
| - mime_type->data());
|
| + bool eq = !mime_type->empty() &&
|
| + LowerCaseEqualsASCII(
|
| + begin + type_val, begin + type_end, mime_type->data());
|
| if (!eq) {
|
| mime_type->assign(begin + type_val, begin + type_end);
|
| StringToLowerASCII(mime_type);
|
| @@ -212,8 +210,8 @@ bool HttpUtil::ParseRangeHeader(const std::string& ranges_specifier,
|
|
|
| // Try to extract bytes-unit part.
|
| std::string::const_iterator bytes_unit_begin = ranges_specifier.begin();
|
| - std::string::const_iterator bytes_unit_end = bytes_unit_begin +
|
| - equal_char_offset;
|
| + std::string::const_iterator bytes_unit_end =
|
| + bytes_unit_begin + equal_char_offset;
|
| std::string::const_iterator byte_range_set_begin = bytes_unit_end + 1;
|
| std::string::const_iterator byte_range_set_end = ranges_specifier.end();
|
|
|
| @@ -222,8 +220,8 @@ bool HttpUtil::ParseRangeHeader(const std::string& ranges_specifier,
|
| if (!LowerCaseEqualsASCII(bytes_unit_begin, bytes_unit_end, "bytes"))
|
| return false;
|
|
|
| - ValuesIterator byte_range_set_iterator(byte_range_set_begin,
|
| - byte_range_set_end, ',');
|
| + ValuesIterator byte_range_set_iterator(
|
| + byte_range_set_begin, byte_range_set_end, ',');
|
| while (byte_range_set_iterator.GetNext()) {
|
| size_t minus_char_offset = byte_range_set_iterator.value().find('-');
|
| // If '-' character is not found, reports failure.
|
| @@ -233,7 +231,7 @@ bool HttpUtil::ParseRangeHeader(const std::string& ranges_specifier,
|
| std::string::const_iterator first_byte_pos_begin =
|
| byte_range_set_iterator.value_begin();
|
| std::string::const_iterator first_byte_pos_end =
|
| - first_byte_pos_begin + minus_char_offset;
|
| + first_byte_pos_begin + minus_char_offset;
|
| TrimLWS(&first_byte_pos_begin, &first_byte_pos_end);
|
| std::string first_byte_pos(first_byte_pos_begin, first_byte_pos_end);
|
|
|
| @@ -302,27 +300,17 @@ namespace {
|
| // an error. The list comes from the XMLHttpRequest standard.
|
| // http://www.w3.org/TR/XMLHttpRequest/#the-setrequestheader-method
|
| const char* const kForbiddenHeaderFields[] = {
|
| - "accept-charset",
|
| - "accept-encoding",
|
| - "access-control-request-headers",
|
| - "access-control-request-method",
|
| - "connection",
|
| - "content-length",
|
| - "cookie",
|
| - "cookie2",
|
| - "content-transfer-encoding",
|
| - "date",
|
| - "expect",
|
| - "host",
|
| - "keep-alive",
|
| - "origin",
|
| - "referer",
|
| - "te",
|
| - "trailer",
|
| - "transfer-encoding",
|
| - "upgrade",
|
| - "user-agent",
|
| - "via",
|
| + "accept-charset", "accept-encoding",
|
| + "access-control-request-headers", "access-control-request-method",
|
| + "connection", "content-length",
|
| + "cookie", "cookie2",
|
| + "content-transfer-encoding", "date",
|
| + "expect", "host",
|
| + "keep-alive", "origin",
|
| + "referer", "te",
|
| + "trailer", "transfer-encoding",
|
| + "upgrade", "user-agent",
|
| + "via",
|
| };
|
| } // anonymous namespace
|
|
|
| @@ -349,8 +337,8 @@ std::string HttpUtil::StripHeaders(const std::string& headers,
|
| while (it.GetNext()) {
|
| bool should_remove = false;
|
| for (size_t i = 0; i < headers_to_remove_len; ++i) {
|
| - if (LowerCaseEqualsASCII(it.name_begin(), it.name_end(),
|
| - headers_to_remove[i])) {
|
| + if (LowerCaseEqualsASCII(
|
| + it.name_begin(), it.name_end(), headers_to_remove[i])) {
|
| should_remove = true;
|
| break;
|
| }
|
| @@ -370,20 +358,15 @@ bool HttpUtil::IsNonCoalescingHeader(std::string::const_iterator name_begin,
|
| // NOTE: "set-cookie2" headers do not support expires attributes, so we don't
|
| // have to list them here.
|
| const char* kNonCoalescingHeaders[] = {
|
| - "date",
|
| - "expires",
|
| - "last-modified",
|
| - "location", // See bug 1050541 for details
|
| - "retry-after",
|
| - "set-cookie",
|
| - // The format of auth-challenges mixes both space separated tokens and
|
| - // comma separated properties, so coalescing on comma won't work.
|
| - "www-authenticate",
|
| - "proxy-authenticate",
|
| - // STS specifies that UAs must not process any STS headers after the first
|
| - // one.
|
| - "strict-transport-security"
|
| - };
|
| + "date", "expires", "last-modified",
|
| + "location", // See bug 1050541 for details
|
| + "retry-after", "set-cookie",
|
| + // The format of auth-challenges mixes both space separated tokens and
|
| + // comma separated properties, so coalescing on comma won't work.
|
| + "www-authenticate", "proxy-authenticate",
|
| + // STS specifies that UAs must not process any STS headers after the first
|
| + // one.
|
| + "strict-transport-security"};
|
| for (size_t i = 0; i < arraysize(kNonCoalescingHeaders); ++i) {
|
| if (LowerCaseEqualsASCII(name_begin, name_end, kNonCoalescingHeaders[i]))
|
| return true;
|
| @@ -419,11 +402,10 @@ bool HttpUtil::IsToken(std::string::const_iterator begin,
|
| return false;
|
| for (std::string::const_iterator iter = begin; iter != end; ++iter) {
|
| unsigned char c = *iter;
|
| - if (c >= 0x80 || c <= 0x1F || c == 0x7F ||
|
| - c == '(' || c == ')' || c == '<' || c == '>' || c == '@' ||
|
| - c == ',' || c == ';' || c == ':' || c == '\\' || c == '"' ||
|
| - c == '/' || c == '[' || c == ']' || c == '?' || c == '=' ||
|
| - c == '{' || c == '}' || c == ' ' || c == '\t')
|
| + if (c >= 0x80 || c <= 0x1F || c == 0x7F || c == '(' || c == ')' ||
|
| + c == '<' || c == '>' || c == '@' || c == ',' || c == ';' || c == ':' ||
|
| + c == '\\' || c == '"' || c == '/' || c == '[' || c == ']' || c == '?' ||
|
| + c == '=' || c == '{' || c == '}' || c == ' ' || c == '\t')
|
| return false;
|
| }
|
| return true;
|
| @@ -660,8 +642,8 @@ std::string HttpUtil::GenerateAcceptLanguageHeader(
|
| lang_list_with_q = language;
|
| } else {
|
| DCHECK_LT(qvalue10, 10U);
|
| - base::StringAppendF(&lang_list_with_q, ",%s;q=0.%d", language.c_str(),
|
| - qvalue10);
|
| + base::StringAppendF(
|
| + &lang_list_with_q, ",%s;q=0.%d", language.c_str(), qvalue10);
|
| }
|
| // It does not make sense to have 'q=0'.
|
| if (qvalue10 > kQvalueDecrement10)
|
| @@ -723,11 +705,12 @@ enum {
|
| // static
|
| std::vector<int> HttpUtil::GetStatusCodesForHistogram() {
|
| std::vector<int> codes;
|
| - codes.reserve(
|
| - HISTOGRAM_MAX_HTTP_STATUS_CODE - HISTOGRAM_MIN_HTTP_STATUS_CODE + 2);
|
| + codes.reserve(HISTOGRAM_MAX_HTTP_STATUS_CODE -
|
| + HISTOGRAM_MIN_HTTP_STATUS_CODE + 2);
|
| codes.push_back(0);
|
| for (int i = HISTOGRAM_MIN_HTTP_STATUS_CODE;
|
| - i <= HISTOGRAM_MAX_HTTP_STATUS_CODE; ++i)
|
| + i <= HISTOGRAM_MAX_HTTP_STATUS_CODE;
|
| + ++i)
|
| codes.push_back(i);
|
| return codes;
|
| }
|
| @@ -841,7 +824,8 @@ HttpUtil::NameValuePairsIterator::NameValuePairsIterator(
|
| value_is_quoted_(false) {
|
| }
|
|
|
| -HttpUtil::NameValuePairsIterator::~NameValuePairsIterator() {}
|
| +HttpUtil::NameValuePairsIterator::~NameValuePairsIterator() {
|
| +}
|
|
|
| // We expect properties to be formatted as one of:
|
| // name="value"
|
|
|