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

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

Issue 314083002: parseHTTPHeaders should return the number of consumed bytes. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@async-initializer
Patch Set: Created 6 years, 6 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
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 650 matching lines...) Expand 10 before | Expand all | Expand 10 after
661 failureReason = "LF doesn't follow CR after value at " + trimInputSample (&s[i + 1], size - i - 1); 661 failureReason = "LF doesn't follow CR after value at " + trimInputSample (&s[i + 1], size - i - 1);
662 return false; 662 return false;
663 } 663 }
664 664
665 *value = AtomicString::fromUTF8(&s[valueBegin], i - valueBegin); 665 *value = AtomicString::fromUTF8(&s[valueBegin], i - valueBegin);
666 if (i != valueBegin && value->isNull()) { 666 if (i != valueBegin && value->isNull()) {
667 failureReason = "Invalid UTF-8 sequence in header value"; 667 failureReason = "Invalid UTF-8 sequence in header value";
668 return false; 668 return false;
669 } 669 }
670 670
671 *position = i + 1; 671 // 2 for strlen("\r\n")
672 *position = i + 2;
672 return true; 673 return true;
673 } 674 }
674 675
675 // Note that the header is already parsed and re-formatted in chromium side. 676 // Note that the header is already parsed and re-formatted in chromium side.
676 // We assume that the input is more restricted than RFC2616. 677 // We assume that the input is more restricted than RFC2616.
677 size_t parseHTTPHeader(const char* s, size_t size, String& failureReason, Atomic String& name, AtomicString& value) 678 size_t parseHTTPHeader(const char* s, size_t size, String& failureReason, Atomic String& name, AtomicString& value)
678 { 679 {
679 name = nullAtom; 680 name = nullAtom;
680 value = nullAtom; 681 value = nullAtom;
681 if (size >= 1 && s[0] == '\r') { 682 if (size >= 1 && s[0] == '\r') {
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
844 if (!cacheControlHeader.containsNoCache) { 845 if (!cacheControlHeader.containsNoCache) {
845 // Handle Pragma: no-cache 846 // Handle Pragma: no-cache
846 // This is deprecated and equivalent to Cache-control: no-cache 847 // This is deprecated and equivalent to Cache-control: no-cache
847 // Don't bother tokenizing the value, it is not important 848 // Don't bother tokenizing the value, it is not important
848 cacheControlHeader.containsNoCache = pragmaValue.lower().contains(noCach eDirective); 849 cacheControlHeader.containsNoCache = pragmaValue.lower().contains(noCach eDirective);
849 } 850 }
850 return cacheControlHeader; 851 return cacheControlHeader;
851 } 852 }
852 853
853 } 854 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698