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

Side by Side Diff: Source/platform/network/HTTPParsers.cpp

Issue 99733002: Update HTTPHeaderMap wrappers to use AtomicString type for header values (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase on master Created 7 years 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
« no previous file with comments | « Source/platform/network/HTTPParsers.h ('k') | Source/platform/network/HTTPRequest.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org) 2 * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org)
3 * Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. 3 * Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
4 * Copyright (C) 2009 Torch Mobile Inc. http://www.torchmobile.com/ 4 * Copyright (C) 2009 Torch Mobile Inc. http://www.torchmobile.com/
5 * Copyright (C) 2009 Google Inc. All rights reserved. 5 * Copyright (C) 2009 Google Inc. All rights reserved.
6 * Copyright (C) 2011 Apple Inc. All Rights Reserved. 6 * Copyright (C) 2011 Apple Inc. All Rights Reserved.
7 * 7 *
8 * Redistribution and use in source and binary forms, with or without 8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions 9 * modification, are permitted provided that the following conditions
10 * are met: 10 * are met:
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 // Remove quotes if there are any 259 // Remove quotes if there are any
260 if (value[0] == '\"') 260 if (value[0] == '\"')
261 value = value.substring(1, value.length() - 2); 261 value = value.substring(1, value.length() - 2);
262 262
263 return value; 263 return value;
264 } 264 }
265 265
266 return String(); 266 return String();
267 } 267 }
268 268
269 String extractMIMETypeFromMediaType(const String& mediaType) 269 AtomicString extractMIMETypeFromMediaType(const AtomicString& mediaType)
270 { 270 {
271 StringBuilder mimeType; 271 StringBuilder mimeType;
272 unsigned length = mediaType.length(); 272 unsigned length = mediaType.length();
273 mimeType.reserveCapacity(length); 273 mimeType.reserveCapacity(length);
274 for (unsigned i = 0; i < length; i++) { 274 for (unsigned i = 0; i < length; i++) {
275 UChar c = mediaType[i]; 275 UChar c = mediaType[i];
276 276
277 if (c == ';') 277 if (c == ';')
278 break; 278 break;
279 279
(...skipping 11 matching lines...) Expand all
291 // includes only a few specific ASCII characters; a small subset of isSp aceOrNewline. 291 // includes only a few specific ASCII characters; a small subset of isSp aceOrNewline.
292 // See https://bugs.webkit.org/show_bug.cgi?id=8644 for a bug tracking p art of this. 292 // See https://bugs.webkit.org/show_bug.cgi?id=8644 for a bug tracking p art of this.
293 if (isSpaceOrNewline(c)) 293 if (isSpaceOrNewline(c))
294 continue; 294 continue;
295 295
296 mimeType.append(c); 296 mimeType.append(c);
297 } 297 }
298 298
299 if (mimeType.length() == length) 299 if (mimeType.length() == length)
300 return mediaType; 300 return mediaType;
301 return mimeType.toString(); 301 return mimeType.toAtomicString();
302 } 302 }
303 303
304 String extractCharsetFromMediaType(const String& mediaType) 304 String extractCharsetFromMediaType(const String& mediaType)
305 { 305 {
306 unsigned pos, len; 306 unsigned pos, len;
307 findCharsetInMediaType(mediaType, pos, len); 307 findCharsetInMediaType(mediaType, pos, len);
308 return mediaType.substring(pos, len); 308 return mediaType.substring(pos, len);
309 } 309 }
310 310
311 void findCharsetInMediaType(const String& mediaType, unsigned& charsetPos, unsig ned& charsetLen, unsigned start) 311 void findCharsetInMediaType(const String& mediaType, unsigned& charsetPos, unsig ned& charsetLen, unsigned start)
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
600 else if (httpVersionString[7] == '0') 600 else if (httpVersionString[7] == '0')
601 httpVersion = HTTP_1_0; 601 httpVersion = HTTP_1_0;
602 else if (httpVersionString[7] == '1') 602 else if (httpVersionString[7] == '1')
603 httpVersion = HTTP_1_1; 603 httpVersion = HTTP_1_1;
604 else 604 else
605 httpVersion = Unknown; 605 httpVersion = Unknown;
606 606
607 return end - data; 607 return end - data;
608 } 608 }
609 609
610 size_t parseHTTPHeader(const char* start, size_t length, String& failureReason, AtomicString& nameStr, String& valueStr) 610 size_t parseHTTPHeader(const char* start, size_t length, String& failureReason, AtomicString& nameStr, AtomicString& valueStr)
611 { 611 {
612 const char* p = start; 612 const char* p = start;
613 const char* end = start + length; 613 const char* end = start + length;
614 614
615 Vector<char> name; 615 Vector<char> name;
616 Vector<char> value; 616 Vector<char> value;
617 nameStr = AtomicString(); 617 nameStr = nullAtom;
618 valueStr = String(); 618 valueStr = nullAtom;
619 619
620 for (; p < end; p++) { 620 for (; p < end; p++) {
621 switch (*p) { 621 switch (*p) {
622 case '\r': 622 case '\r':
623 if (name.isEmpty()) { 623 if (name.isEmpty()) {
624 if (p + 1 < end && *(p + 1) == '\n') 624 if (p + 1 < end && *(p + 1) == '\n')
625 return (p + 2) - start; 625 return (p + 2) - start;
626 failureReason = "CR doesn't follow LF at " + trimInputSample(p, end - p); 626 failureReason = "CR doesn't follow LF at " + trimInputSample(p, end - p);
627 return 0; 627 return 0;
628 } 628 }
(...skipping 29 matching lines...) Expand all
658 if (*p == '\r') { 658 if (*p == '\r') {
659 ++p; 659 ++p;
660 break; 660 break;
661 } 661 }
662 } 662 }
663 if (p >= end || *p != '\n') { 663 if (p >= end || *p != '\n') {
664 failureReason = "CR doesn't follow LF after value at " + trimInputSample (p, end - p); 664 failureReason = "CR doesn't follow LF after value at " + trimInputSample (p, end - p);
665 return 0; 665 return 0;
666 } 666 }
667 nameStr = AtomicString::fromUTF8(name.data(), name.size()); 667 nameStr = AtomicString::fromUTF8(name.data(), name.size());
668 valueStr = String::fromUTF8(value.data(), value.size()); 668 valueStr = AtomicString::fromUTF8(value.data(), value.size());
669 if (nameStr.isNull()) { 669 if (nameStr.isNull()) {
670 failureReason = "Invalid UTF-8 sequence in header name"; 670 failureReason = "Invalid UTF-8 sequence in header name";
671 return 0; 671 return 0;
672 } 672 }
673 if (valueStr.isNull()) { 673 if (valueStr.isNull()) {
674 failureReason = "Invalid UTF-8 sequence in header value"; 674 failureReason = "Invalid UTF-8 sequence in header value";
675 return 0; 675 return 0;
676 } 676 }
677 return p - start; 677 return p - start;
678 } 678 }
679 679
680 size_t parseHTTPRequestBody(const char* data, size_t length, Vector<unsigned cha r>& body) 680 size_t parseHTTPRequestBody(const char* data, size_t length, Vector<unsigned cha r>& body)
681 { 681 {
682 body.clear(); 682 body.clear();
683 body.append(data, length); 683 body.append(data, length);
684 684
685 return length; 685 return length;
686 } 686 }
687 687
688 } 688 }
OLDNEW
« no previous file with comments | « Source/platform/network/HTTPParsers.h ('k') | Source/platform/network/HTTPRequest.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698