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 _HttpHeaders(String this.protocolVersion) | 8 _HttpHeaders(String this.protocolVersion) |
9 : _headers = new Map<String, List<String>>(); | 9 : _headers = new Map<String, List<String>>(); |
10 | 10 |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 } else { | 200 } else { |
201 return null; | 201 return null; |
202 } | 202 } |
203 } | 203 } |
204 | 204 |
205 void set contentType(ContentType contentType) { | 205 void set contentType(ContentType contentType) { |
206 _checkMutable(); | 206 _checkMutable(); |
207 _set(HttpHeaders.CONTENT_TYPE, contentType.toString()); | 207 _set(HttpHeaders.CONTENT_TYPE, contentType.toString()); |
208 } | 208 } |
209 | 209 |
210 void _add(String name, Object value) { | 210 void _add(String name, value) { |
211 var lowerCaseName = name.toLowerCase(); | 211 var lowerCaseName = name.toLowerCase(); |
212 // TODO(sgjesse): Add immutable state throw HttpException is immutable. | 212 // TODO(sgjesse): Add immutable state throw HttpException is immutable. |
213 if (lowerCaseName == HttpHeaders.CONTENT_LENGTH) { | 213 if (lowerCaseName == HttpHeaders.CONTENT_LENGTH) { |
214 if (value is int) { | 214 if (value is int) { |
215 contentLength = value; | 215 contentLength = value; |
216 } else if (value is String) { | 216 } else if (value is String) { |
217 contentLength = int.parse(value); | 217 contentLength = int.parse(value); |
218 } else { | 218 } else { |
219 throw new HttpException("Unexpected type for header named $name"); | 219 throw new HttpException("Unexpected type for header named $name"); |
220 } | 220 } |
(...skipping 22 matching lines...) Expand all Loading... |
243 } else if (lowerCaseName == HttpHeaders.IF_MODIFIED_SINCE) { | 243 } else if (lowerCaseName == HttpHeaders.IF_MODIFIED_SINCE) { |
244 if (value is DateTime) { | 244 if (value is DateTime) { |
245 ifModifiedSince = value; | 245 ifModifiedSince = value; |
246 } else if (value is String) { | 246 } else if (value is String) { |
247 _set(HttpHeaders.IF_MODIFIED_SINCE, value); | 247 _set(HttpHeaders.IF_MODIFIED_SINCE, value); |
248 } else { | 248 } else { |
249 throw new HttpException("Unexpected type for header named $name"); | 249 throw new HttpException("Unexpected type for header named $name"); |
250 } | 250 } |
251 } else if (lowerCaseName == HttpHeaders.HOST) { | 251 } else if (lowerCaseName == HttpHeaders.HOST) { |
252 if (value is String) { | 252 if (value is String) { |
253 int pos = (value as String).indexOf(":"); | 253 int pos = value.indexOf(":"); |
254 if (pos == -1) { | 254 if (pos == -1) { |
255 _host = value; | 255 _host = value; |
256 _port = HttpClient.DEFAULT_HTTP_PORT; | 256 _port = HttpClient.DEFAULT_HTTP_PORT; |
257 } else { | 257 } else { |
258 if (pos > 0) { | 258 if (pos > 0) { |
259 _host = (value as String).substring(0, pos); | 259 _host = value.substring(0, pos); |
260 } else { | 260 } else { |
261 _host = null; | 261 _host = null; |
262 } | 262 } |
263 if (pos + 1 == value.length) { | 263 if (pos + 1 == value.length) { |
264 _port = HttpClient.DEFAULT_HTTP_PORT; | 264 _port = HttpClient.DEFAULT_HTTP_PORT; |
265 } else { | 265 } else { |
266 try { | 266 try { |
267 _port = int.parse(value.substring(pos + 1)); | 267 _port = int.parse(value.substring(pos + 1)); |
268 } on FormatException catch (e) { | 268 } on FormatException catch (e) { |
269 _port = null; | 269 _port = null; |
(...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
771 | 771 |
772 String name; | 772 String name; |
773 String value; | 773 String value; |
774 DateTime expires; | 774 DateTime expires; |
775 int maxAge; | 775 int maxAge; |
776 String domain; | 776 String domain; |
777 String path; | 777 String path; |
778 bool httpOnly = false; | 778 bool httpOnly = false; |
779 bool secure = false; | 779 bool secure = false; |
780 } | 780 } |
OLD | NEW |