| 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 // 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> | 
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 211     return false; | 211     return false; | 
| 212 | 212 | 
| 213   // ensure match is suffixed by colon | 213   // ensure match is suffixed by colon | 
| 214   if (it + name_len >= headers.end() || it[name_len] != ':') | 214   if (it + name_len >= headers.end() || it[name_len] != ':') | 
| 215     return false; | 215     return false; | 
| 216 | 216 | 
| 217   return true; | 217   return true; | 
| 218 } | 218 } | 
| 219 | 219 | 
| 220 // static | 220 // static | 
|  | 221 std::string HttpUtil::StripHeaders(const std::string& headers, | 
|  | 222                                    const char* const headers_to_remove[], | 
|  | 223                                    size_t headers_to_remove_len) { | 
|  | 224   std::string stripped_headers; | 
|  | 225   net::HttpUtil::HeadersIterator it(headers.begin(), headers.end(), "\r\n"); | 
|  | 226 | 
|  | 227   while (it.GetNext()) { | 
|  | 228     bool should_remove = false; | 
|  | 229     for (size_t i = 0; i < headers_to_remove_len; ++i) { | 
|  | 230       if (LowerCaseEqualsASCII(it.name_begin(), it.name_end(), | 
|  | 231                                headers_to_remove[i])) { | 
|  | 232         should_remove = true; | 
|  | 233         break; | 
|  | 234       } | 
|  | 235     } | 
|  | 236     if (!should_remove) { | 
|  | 237       // Assume that name and values are on the same line. | 
|  | 238       stripped_headers.append(it.name_begin(), it.values_end()); | 
|  | 239       stripped_headers.append("\r\n"); | 
|  | 240     } | 
|  | 241   } | 
|  | 242   return stripped_headers; | 
|  | 243 } | 
|  | 244 | 
|  | 245 // static | 
| 221 bool HttpUtil::IsNonCoalescingHeader(string::const_iterator name_begin, | 246 bool HttpUtil::IsNonCoalescingHeader(string::const_iterator name_begin, | 
| 222                                      string::const_iterator name_end) { | 247                                      string::const_iterator name_end) { | 
| 223   // NOTE: "set-cookie2" headers do not support expires attributes, so we don't | 248   // NOTE: "set-cookie2" headers do not support expires attributes, so we don't | 
| 224   // have to list them here. | 249   // have to list them here. | 
| 225   const char* kNonCoalescingHeaders[] = { | 250   const char* kNonCoalescingHeaders[] = { | 
| 226     "date", | 251     "date", | 
| 227     "expires", | 252     "expires", | 
| 228     "last-modified", | 253     "last-modified", | 
| 229     "location",  // See bug 1050541 for details | 254     "location",  // See bug 1050541 for details | 
| 230     "retry-after", | 255     "retry-after", | 
| (...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 556     TrimLWS(&value_begin_, &value_end_); | 581     TrimLWS(&value_begin_, &value_end_); | 
| 557 | 582 | 
| 558     // bypass empty values. | 583     // bypass empty values. | 
| 559     if (value_begin_ != value_end_) | 584     if (value_begin_ != value_end_) | 
| 560       return true; | 585       return true; | 
| 561   } | 586   } | 
| 562   return false; | 587   return false; | 
| 563 } | 588 } | 
| 564 | 589 | 
| 565 }  // namespace net | 590 }  // namespace net | 
| OLD | NEW | 
|---|