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

Side by Side Diff: net/http/http_content_disposition.cc

Issue 448143008: Move StringToUpperASCII and LowerCaseEqualsASCII to the base namespace (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/http/http_cache_transaction.cc ('k') | net/http/http_log_util.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "net/http/http_content_disposition.h" 5 #include "net/http/http_content_disposition.h"
6 6
7 #include "base/base64.h" 7 #include "base/base64.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/strings/string_tokenizer.h" 9 #include "base/strings/string_tokenizer.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 // If the disposition-type isn't a valid token the then the 354 // If the disposition-type isn't a valid token the then the
355 // Content-Disposition header is malformed, and we treat the first bytes as 355 // Content-Disposition header is malformed, and we treat the first bytes as
356 // a parameter rather than a disposition-type. 356 // a parameter rather than a disposition-type.
357 if (!HttpUtil::IsToken(type_begin, type_end)) 357 if (!HttpUtil::IsToken(type_begin, type_end))
358 return begin; 358 return begin;
359 359
360 parse_result_flags_ |= HAS_DISPOSITION_TYPE; 360 parse_result_flags_ |= HAS_DISPOSITION_TYPE;
361 361
362 DCHECK(std::find(type_begin, type_end, '=') == type_end); 362 DCHECK(std::find(type_begin, type_end, '=') == type_end);
363 363
364 if (LowerCaseEqualsASCII(type_begin, type_end, "inline")) { 364 if (base::LowerCaseEqualsASCII(type_begin, type_end, "inline")) {
365 type_ = INLINE; 365 type_ = INLINE;
366 } else if (LowerCaseEqualsASCII(type_begin, type_end, "attachment")) { 366 } else if (base::LowerCaseEqualsASCII(type_begin, type_end, "attachment")) {
367 type_ = ATTACHMENT; 367 type_ = ATTACHMENT;
368 } else { 368 } else {
369 parse_result_flags_ |= HAS_UNKNOWN_DISPOSITION_TYPE; 369 parse_result_flags_ |= HAS_UNKNOWN_DISPOSITION_TYPE;
370 type_ = ATTACHMENT; 370 type_ = ATTACHMENT;
371 } 371 }
372 return delimiter; 372 return delimiter;
373 } 373 }
374 374
375 // http://tools.ietf.org/html/rfc6266 375 // http://tools.ietf.org/html/rfc6266
376 // 376 //
(...skipping 21 matching lines...) Expand all
398 std::string::const_iterator pos = header.begin(); 398 std::string::const_iterator pos = header.begin();
399 std::string::const_iterator end = header.end(); 399 std::string::const_iterator end = header.end();
400 pos = ConsumeDispositionType(pos, end); 400 pos = ConsumeDispositionType(pos, end);
401 401
402 std::string name; 402 std::string name;
403 std::string filename; 403 std::string filename;
404 std::string ext_filename; 404 std::string ext_filename;
405 405
406 HttpUtil::NameValuePairsIterator iter(pos, end, ';'); 406 HttpUtil::NameValuePairsIterator iter(pos, end, ';');
407 while (iter.GetNext()) { 407 while (iter.GetNext()) {
408 if (filename.empty() && LowerCaseEqualsASCII(iter.name_begin(), 408 if (filename.empty() && base::LowerCaseEqualsASCII(iter.name_begin(),
409 iter.name_end(), 409 iter.name_end(),
410 "filename")) { 410 "filename")) {
411 DecodeFilenameValue(iter.value(), referrer_charset, &filename, 411 DecodeFilenameValue(iter.value(), referrer_charset, &filename,
412 &parse_result_flags_); 412 &parse_result_flags_);
413 if (!filename.empty()) 413 if (!filename.empty())
414 parse_result_flags_ |= HAS_FILENAME; 414 parse_result_flags_ |= HAS_FILENAME;
415 } else if (name.empty() && LowerCaseEqualsASCII(iter.name_begin(), 415 } else if (name.empty() && base::LowerCaseEqualsASCII(iter.name_begin(),
416 iter.name_end(), 416 iter.name_end(),
417 "name")) { 417 "name")) {
418 DecodeFilenameValue(iter.value(), referrer_charset, &name, NULL); 418 DecodeFilenameValue(iter.value(), referrer_charset, &name, NULL);
419 if (!name.empty()) 419 if (!name.empty())
420 parse_result_flags_ |= HAS_NAME; 420 parse_result_flags_ |= HAS_NAME;
421 } else if (ext_filename.empty() && LowerCaseEqualsASCII(iter.name_begin(), 421 } else if (ext_filename.empty() &&
422 iter.name_end(), 422 base::LowerCaseEqualsASCII(iter.name_begin(), iter.name_end(),
423 "filename*")) { 423 "filename*")) {
424 DecodeExtValue(iter.raw_value(), &ext_filename); 424 DecodeExtValue(iter.raw_value(), &ext_filename);
425 if (!ext_filename.empty()) 425 if (!ext_filename.empty())
426 parse_result_flags_ |= HAS_EXT_FILENAME; 426 parse_result_flags_ |= HAS_EXT_FILENAME;
427 } 427 }
428 } 428 }
429 429
430 if (!ext_filename.empty()) 430 if (!ext_filename.empty())
431 filename_ = ext_filename; 431 filename_ = ext_filename;
432 else if (!filename.empty()) 432 else if (!filename.empty())
433 filename_ = filename; 433 filename_ = filename;
434 else 434 else
435 filename_ = name; 435 filename_ = name;
436 } 436 }
437 437
438 } // namespace net 438 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_cache_transaction.cc ('k') | net/http/http_log_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698