| 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 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 | 116 |
| 117 void set contentLength(int contentLength) { | 117 void set contentLength(int contentLength) { |
| 118 _checkMutable(); | 118 _checkMutable(); |
| 119 if (protocolVersion == "1.0" && | 119 if (protocolVersion == "1.0" && |
| 120 persistentConnection && | 120 persistentConnection && |
| 121 contentLength == -1) { | 121 contentLength == -1) { |
| 122 throw new HttpException( | 122 throw new HttpException( |
| 123 "Trying to clear ContentLength on HTTP 1.0 headers with " | 123 "Trying to clear ContentLength on HTTP 1.0 headers with " |
| 124 "'Connection: Keep-Alive' set"); | 124 "'Connection: Keep-Alive' set"); |
| 125 } | 125 } |
| 126 if (_contentLength == contentLength) return; |
| 126 _contentLength = contentLength; | 127 _contentLength = contentLength; |
| 127 if (_contentLength >= 0) { | 128 if (_contentLength >= 0) { |
| 128 if (chunkedTransferEncoding) chunkedTransferEncoding = false; | 129 if (chunkedTransferEncoding) chunkedTransferEncoding = false; |
| 129 _set(HttpHeaders.CONTENT_LENGTH, contentLength.toString()); | 130 _set(HttpHeaders.CONTENT_LENGTH, contentLength.toString()); |
| 130 } else { | 131 } else { |
| 131 removeAll(HttpHeaders.CONTENT_LENGTH); | 132 removeAll(HttpHeaders.CONTENT_LENGTH); |
| 133 if (protocolVersion == "1.1") { |
| 134 chunkedTransferEncoding = true; |
| 135 } |
| 132 } | 136 } |
| 133 } | 137 } |
| 134 | 138 |
| 135 bool get chunkedTransferEncoding => _chunkedTransferEncoding; | 139 bool get chunkedTransferEncoding => _chunkedTransferEncoding; |
| 136 | 140 |
| 137 void set chunkedTransferEncoding(bool chunkedTransferEncoding) { | 141 void set chunkedTransferEncoding(bool chunkedTransferEncoding) { |
| 138 _checkMutable(); | 142 _checkMutable(); |
| 139 if (chunkedTransferEncoding && protocolVersion == "1.0") { | 143 if (chunkedTransferEncoding && protocolVersion == "1.0") { |
| 140 throw new HttpException( | 144 throw new HttpException( |
| 141 "Trying to set 'Transfer-Encoding: Chunked' on HTTP 1.0 headers"); | 145 "Trying to set 'Transfer-Encoding: Chunked' on HTTP 1.0 headers"); |
| (...skipping 697 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 839 void clear() { | 843 void clear() { |
| 840 throw new UnsupportedError("Cannot modify an unmodifiable map"); | 844 throw new UnsupportedError("Cannot modify an unmodifiable map"); |
| 841 } | 845 } |
| 842 void forEach(void f(K key, V value)) => _map.forEach(f); | 846 void forEach(void f(K key, V value)) => _map.forEach(f); |
| 843 Iterable<K> get keys => _map.keys; | 847 Iterable<K> get keys => _map.keys; |
| 844 Iterable<V> get values => _map.values; | 848 Iterable<V> get values => _map.values; |
| 845 int get length => _map.length; | 849 int get length => _map.length; |
| 846 bool get isEmpty => _map.isEmpty; | 850 bool get isEmpty => _map.isEmpty; |
| 847 bool get isNotEmpty => _map.isNotEmpty; | 851 bool get isNotEmpty => _map.isNotEmpty; |
| 848 } | 852 } |
| OLD | NEW |