OLD | NEW |
---|---|
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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
53 } | 53 } |
54 } else { | 54 } else { |
55 _add(name, _validateValue(value)); | 55 _add(name, _validateValue(value)); |
56 } | 56 } |
57 } | 57 } |
58 | 58 |
59 void set(String name, Object value) { | 59 void set(String name, Object value) { |
60 _checkMutable(); | 60 _checkMutable(); |
61 name = _validateField(name); | 61 name = _validateField(name); |
62 _headers.remove(name); | 62 _headers.remove(name); |
63 if (name == HttpHeaders.TRANSFER_ENCODING) { | |
Anders Johnsen
2014/08/11 12:39:55
This should hit the _add switch below, right?
Søren Gjesse
2014/08/11 14:20:49
The problem is that the logic invoked by _add will
Anders Johnsen
2014/08/12 05:42:38
I see. We should probably rewrite this logic at so
Søren Gjesse
2014/08/12 06:38:33
That we can absolutely agree on :-)
| |
64 _chunkedTransferEncoding = false; | |
65 } | |
63 _addAll(name, value); | 66 _addAll(name, value); |
64 } | 67 } |
65 | 68 |
66 void remove(String name, Object value) { | 69 void remove(String name, Object value) { |
67 _checkMutable(); | 70 _checkMutable(); |
68 name = _validateField(name); | 71 name = _validateField(name); |
69 value = _validateValue(value); | 72 value = _validateValue(value); |
70 List<String> values = _headers[name]; | 73 List<String> values = _headers[name]; |
71 if (values != null) { | 74 if (values != null) { |
72 int index = values.indexOf(value); | 75 int index = values.indexOf(value); |
73 if (index != -1) { | 76 if (index != -1) { |
74 values.removeRange(index, index + 1); | 77 values.removeRange(index, index + 1); |
75 } | 78 } |
76 if (values.length == 0) _headers.remove(name); | 79 if (values.length == 0) _headers.remove(name); |
77 } | 80 } |
Anders Johnsen
2014/08/11 12:39:56
Ditto.
Søren Gjesse
2014/08/11 14:20:49
This code never calls the _add code.
Anders Johnsen
2014/08/12 05:42:38
Right!
| |
81 if (name == HttpHeaders.TRANSFER_ENCODING && value == "chunked") { | |
82 _chunkedTransferEncoding = false; | |
83 } | |
78 } | 84 } |
79 | 85 |
80 void removeAll(String name) { | 86 void removeAll(String name) { |
81 _checkMutable(); | 87 _checkMutable(); |
82 name = _validateField(name); | 88 name = _validateField(name); |
83 _headers.remove(name); | 89 _headers.remove(name); |
84 } | 90 } |
85 | 91 |
86 void forEach(void f(String name, List<String> values)) { | 92 void forEach(void f(String name, List<String> values)) { |
87 _headers.forEach(f); | 93 _headers.forEach(f); |
(...skipping 847 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
935 (codeUnit >= 0x23 && codeUnit <= 0x2B) || | 941 (codeUnit >= 0x23 && codeUnit <= 0x2B) || |
936 (codeUnit >= 0x2D && codeUnit <= 0x3A) || | 942 (codeUnit >= 0x2D && codeUnit <= 0x3A) || |
937 (codeUnit >= 0x3C && codeUnit <= 0x5B) || | 943 (codeUnit >= 0x3C && codeUnit <= 0x5B) || |
938 (codeUnit >= 0x5D && codeUnit <= 0x7E))) { | 944 (codeUnit >= 0x5D && codeUnit <= 0x7E))) { |
939 throw new FormatException( | 945 throw new FormatException( |
940 "Invalid character in cookie value, code unit: '$codeUnit'"); | 946 "Invalid character in cookie value, code unit: '$codeUnit'"); |
941 } | 947 } |
942 } | 948 } |
943 } | 949 } |
944 } | 950 } |
OLD | NEW |