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

Side by Side Diff: sdk/lib/io/http_headers.dart

Issue 2225003002: Handle HTTP header parameters with empty values better (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Addressed review comments Created 4 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
« no previous file with comments | « CHANGELOG.md ('k') | tests/standalone/io/http_headers_test.dart » ('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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 part of dart.io; 5 part of dart.io;
6 6
7 class _HttpHeaders implements HttpHeaders { 7 class _HttpHeaders implements HttpHeaders {
8 final Map<String, List<String>> _headers; 8 final Map<String, List<String>> _headers;
9 final String protocolVersion; 9 final String protocolVersion;
10 10
(...skipping 742 matching lines...) Expand 10 before | Expand all | Expand 10 after
753 skipWS(); 753 skipWS();
754 if (done()) return; 754 if (done()) return;
755 String name = parseParameterName(); 755 String name = parseParameterName();
756 skipWS(); 756 skipWS();
757 if (done()) { 757 if (done()) {
758 parameters[name] = null; 758 parameters[name] = null;
759 return; 759 return;
760 } 760 }
761 maybeExpect("="); 761 maybeExpect("=");
762 skipWS(); 762 skipWS();
763 if(done()) { 763 if (done()) {
764 parameters[name] = null; 764 parameters[name] = null;
765 return; 765 return;
766 } 766 }
767 String value = parseParameterValue(); 767 String value = parseParameterValue();
768 if (name == 'charset' && this is _ContentType) { 768 if (name == 'charset' && this is _ContentType && value != null) {
769 // Charset parameter of ContentTypes are always lower-case. 769 // Charset parameter of ContentTypes are always lower-case.
770 value = value.toLowerCase(); 770 value = value.toLowerCase();
771 } 771 }
772 parameters[name] = value; 772 parameters[name] = value;
773 skipWS(); 773 skipWS();
774 if (done()) return; 774 if (done()) return;
775 // TODO: Implement support for multi-valued parameters. 775 // TODO: Implement support for multi-valued parameters.
776 if(s[index] == valueSeparator) return; 776 if(s[index] == valueSeparator) return;
777 expect(parameterSeparator); 777 expect(parameterSeparator);
778 } 778 }
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
990 (codeUnit >= 0x23 && codeUnit <= 0x2B) || 990 (codeUnit >= 0x23 && codeUnit <= 0x2B) ||
991 (codeUnit >= 0x2D && codeUnit <= 0x3A) || 991 (codeUnit >= 0x2D && codeUnit <= 0x3A) ||
992 (codeUnit >= 0x3C && codeUnit <= 0x5B) || 992 (codeUnit >= 0x3C && codeUnit <= 0x5B) ||
993 (codeUnit >= 0x5D && codeUnit <= 0x7E))) { 993 (codeUnit >= 0x5D && codeUnit <= 0x7E))) {
994 throw new FormatException( 994 throw new FormatException(
995 "Invalid character in cookie value, code unit: '$codeUnit'"); 995 "Invalid character in cookie value, code unit: '$codeUnit'");
996 } 996 }
997 } 997 }
998 } 998 }
999 } 999 }
OLDNEW
« no previous file with comments | « CHANGELOG.md ('k') | tests/standalone/io/http_headers_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698