Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(23)

Unified Diff: net/http/http_util.cc

Issue 9296005: Delete net::GetHeaderParamValue (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: net/http/http_util.cc
===================================================================
--- net/http/http_util.cc (revision 119390)
+++ net/http/http_util.cc (working copy)
@@ -90,8 +90,12 @@
// static
void HttpUtil::ParseContentType(const string& content_type_str,
- string* mime_type, string* charset,
- bool *had_charset) {
+ string* mime_type,
+ string* charset,
+ bool *had_charset,
+ string* boundary) {
+ const string::const_iterator begin = content_type_str.begin();
+
// Trim leading and trailing whitespace from type. We include '(' in
// the trailing trim set to catch media-type comments, which are not at all
// standard, but may occur in rare cases.
@@ -121,14 +125,28 @@
static const char charset_str[] = "charset=";
size_t charset_end_offset = std::min(
param_name_start + sizeof(charset_str) - 1, cur_param_end);
- if (LowerCaseEqualsASCII(
- content_type_str.begin() + param_name_start,
- content_type_str.begin() + charset_end_offset, charset_str)) {
+ if (LowerCaseEqualsASCII(begin + param_name_start,
+ begin + charset_end_offset,
+ charset_str)) {
charset_val = param_name_start + sizeof(charset_str) - 1;
charset_end = cur_param_end;
type_has_charset = true;
}
+ static const char boundary_str[] = "boundary=";
asanka 2012/01/27 16:18:59 Isn't *LWSP-char allowed around "="? GetHeaderPar
+ static const size_t boundary_len = sizeof(boundary_str) - 1;
+ size_t boundary_end_offset = std::min(
+ param_name_start + boundary_len, cur_param_end);
+ if (boundary && LowerCaseEqualsASCII(begin + param_name_start,
+ begin + boundary_end_offset,
+ boundary_str)) {
+ string::const_iterator boundary_begin =
+ begin + param_name_start + boundary_len;
+ string::const_iterator boundary_end = begin + cur_param_end;
+ TrimLWS(&boundary_begin, &boundary_end);
+ boundary->assign(boundary_begin, boundary_end);
+ }
+
cur_param_start = cur_param_end + 1;
} while (cur_param_start < content_type_str.length());
}
@@ -162,19 +180,16 @@
content_type_str != "*/*" &&
content_type_str.find_first_of('/') != string::npos) {
// Common case here is that mime_type is empty
- bool eq = !mime_type->empty() &&
- LowerCaseEqualsASCII(content_type_str.begin() + type_val,
- content_type_str.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(content_type_str.begin() + type_val,
- content_type_str.begin() + type_end);
+ mime_type->assign(begin + type_val, begin + type_end);
StringToLowerASCII(mime_type);
}
if ((!eq && *had_charset) || type_has_charset) {
*had_charset = true;
- charset->assign(content_type_str.begin() + charset_val,
- content_type_str.begin() + charset_end);
+ charset->assign(begin + charset_val, begin + charset_end);
StringToLowerASCII(charset);
}
}
« net/http/http_util.h ('K') | « net/http/http_util.h ('k') | net/http/http_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698