| OLD | NEW |
| 1 // Copyright (c) 2012, 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 |
| 11 List<String> operator[](String name) { | 11 List<String> operator[](String name) { |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 } | 240 } |
| 241 } else if (lowerCaseName == "if-modified-since") { | 241 } else if (lowerCaseName == "if-modified-since") { |
| 242 if (value is DateTime) { | 242 if (value is DateTime) { |
| 243 ifModifiedSince = value; | 243 ifModifiedSince = value; |
| 244 } else if (value is String) { | 244 } else if (value is String) { |
| 245 _set("if-modified-since", value); | 245 _set("if-modified-since", value); |
| 246 } else { | 246 } else { |
| 247 throw new HttpException("Unexpected type for header named $name"); | 247 throw new HttpException("Unexpected type for header named $name"); |
| 248 } | 248 } |
| 249 } else if (lowerCaseName == "host") { | 249 } else if (lowerCaseName == "host") { |
| 250 int pos = value.indexOf(":"); | 250 if (value is String) { |
| 251 if (pos == -1) { | 251 int pos = (value as String).indexOf(":"); |
| 252 _host = value; | 252 if (pos == -1) { |
| 253 _port = HttpClient.DEFAULT_HTTP_PORT; | 253 _host = value; |
| 254 } else { | |
| 255 if (pos > 0) { | |
| 256 _host = value.substring(0, pos); | |
| 257 } else { | |
| 258 _host = null; | |
| 259 } | |
| 260 if (pos + 1 == value.length) { | |
| 261 _port = HttpClient.DEFAULT_HTTP_PORT; | 254 _port = HttpClient.DEFAULT_HTTP_PORT; |
| 262 } else { | 255 } else { |
| 263 try { | 256 if (pos > 0) { |
| 264 _port = int.parse(value.substring(pos + 1)); | 257 _host = (value as String).substring(0, pos); |
| 265 } on FormatException catch (e) { | 258 } else { |
| 266 _port = null; | 259 _host = null; |
| 260 } |
| 261 if (pos + 1 == value.length) { |
| 262 _port = HttpClient.DEFAULT_HTTP_PORT; |
| 263 } else { |
| 264 try { |
| 265 _port = int.parse(value.substring(pos + 1)); |
| 266 } on FormatException catch (e) { |
| 267 _port = null; |
| 268 } |
| 267 } | 269 } |
| 268 } | 270 } |
| 271 _set("host", value); |
| 272 } else { |
| 273 throw new HttpException("Unexpected type for header named $name"); |
| 269 } | 274 } |
| 270 _set("host", value); | |
| 271 } else if (lowerCaseName == "content-type") { | 275 } else if (lowerCaseName == "content-type") { |
| 272 _set("content-type", value); | 276 _set("content-type", value); |
| 273 } else { | 277 } else { |
| 274 _addValue(lowerCaseName, value); | 278 _addValue(lowerCaseName, value); |
| 275 } | 279 } |
| 276 } | 280 } |
| 277 | 281 |
| 278 void _addValue(String name, Object value) { | 282 void _addValue(String name, Object value) { |
| 279 List<String> values = _headers[name]; | 283 List<String> values = _headers[name]; |
| 280 if (values == null) { | 284 if (values == null) { |
| (...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 773 | 777 |
| 774 String name; | 778 String name; |
| 775 String value; | 779 String value; |
| 776 DateTime expires; | 780 DateTime expires; |
| 777 int maxAge; | 781 int maxAge; |
| 778 String domain; | 782 String domain; |
| 779 String path; | 783 String path; |
| 780 bool httpOnly = false; | 784 bool httpOnly = false; |
| 781 bool secure = false; | 785 bool secure = false; |
| 782 } | 786 } |
| OLD | NEW |