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 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
313 | 313 |
314 _foldHeader(String name) { | 314 _foldHeader(String name) { |
315 if (name == HttpHeaders.SET_COOKIE || | 315 if (name == HttpHeaders.SET_COOKIE || |
316 (_noFoldingHeaders != null && | 316 (_noFoldingHeaders != null && |
317 _noFoldingHeaders.indexOf(name) != -1)) { | 317 _noFoldingHeaders.indexOf(name) != -1)) { |
318 return false; | 318 return false; |
319 } | 319 } |
320 return true; | 320 return true; |
321 } | 321 } |
322 | 322 |
323 void _finalize() { | 323 void _synchronize() { |
324 // If the content length is not known make sure chunked transfer | 324 // If the content length is not known make sure chunked transfer |
325 // encoding is used for HTTP 1.1. | 325 // encoding is used for HTTP 1.1. |
326 if (contentLength < 0) { | 326 if (contentLength < 0) { |
327 if (protocolVersion == "1.0") { | 327 if (protocolVersion == "1.0") { |
328 persistentConnection = false; | 328 persistentConnection = false; |
329 } else { | 329 } else { |
330 chunkedTransferEncoding = true; | 330 chunkedTransferEncoding = true; |
331 } | 331 } |
332 } | 332 } |
333 // If a Transfer-Encoding header field is present the | 333 // If a Transfer-Encoding header field is present the |
334 // Content-Length header MUST NOT be sent (RFC 2616 section 4.4). | 334 // Content-Length header MUST NOT be sent (RFC 2616 section 4.4). |
335 if (chunkedTransferEncoding && | 335 if (chunkedTransferEncoding && |
336 contentLength >= 0 && | 336 contentLength >= 0 && |
337 protocolVersion == "1.1") { | 337 protocolVersion == "1.1") { |
338 contentLength = -1; | 338 contentLength = -1; |
339 } | 339 } |
| 340 } |
| 341 |
| 342 void _finalize() { |
| 343 _synchronize(); |
340 _mutable = false; | 344 _mutable = false; |
341 } | 345 } |
342 | 346 |
343 _write(IOSink sink) { | 347 _write(IOSink sink) { |
344 final COLONSP = const [_CharCode.COLON, _CharCode.SP]; | 348 final COLONSP = const [_CharCode.COLON, _CharCode.SP]; |
345 final COMMASP = const [_CharCode.COMMA, _CharCode.SP]; | 349 final COMMASP = const [_CharCode.COMMA, _CharCode.SP]; |
346 final CRLF = const [_CharCode.CR, _CharCode.LF]; | 350 final CRLF = const [_CharCode.CR, _CharCode.LF]; |
347 | 351 |
348 var bufferSize = 16 * 1024; | 352 var bufferSize = 16 * 1024; |
349 var buffer = new Uint8List(bufferSize); | 353 var buffer = new Uint8List(bufferSize); |
(...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
783 | 787 |
784 String name; | 788 String name; |
785 String value; | 789 String value; |
786 DateTime expires; | 790 DateTime expires; |
787 int maxAge; | 791 int maxAge; |
788 String domain; | 792 String domain; |
789 String path; | 793 String path; |
790 bool httpOnly = false; | 794 bool httpOnly = false; |
791 bool secure = false; | 795 bool secure = false; |
792 } | 796 } |
OLD | NEW |