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 const int _HEADERS_BUFFER_SIZE = 8 * 1024; | 7 const int _HEADERS_BUFFER_SIZE = 8 * 1024; |
8 | 8 |
9 class _HttpIncoming extends Stream<List<int>> { | 9 class _HttpIncoming extends Stream<List<int>> { |
10 final int _transferLength; | 10 final int _transferLength; |
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
438 charset = "iso-8859-1"; | 438 charset = "iso-8859-1"; |
439 } | 439 } |
440 return Encoding.getByName(charset); | 440 return Encoding.getByName(charset); |
441 } | 441 } |
442 | 442 |
443 void set encoding(Encoding value) { | 443 void set encoding(Encoding value) { |
444 throw new StateError("IOSink encoding is not mutable"); | 444 throw new StateError("IOSink encoding is not mutable"); |
445 } | 445 } |
446 | 446 |
447 void write(Object obj) { | 447 void write(Object obj) { |
| 448 if (!_headersWritten) _dataSink.encoding = encoding; |
448 _dataSink.write(obj); | 449 _dataSink.write(obj); |
449 } | 450 } |
450 | 451 |
451 void writeAll(Iterable objects, [String separator = ""]) { | 452 void writeAll(Iterable objects, [String separator = ""]) { |
| 453 if (!_headersWritten) _dataSink.encoding = encoding; |
452 _dataSink.writeAll(objects, separator); | 454 _dataSink.writeAll(objects, separator); |
453 } | 455 } |
454 | 456 |
455 void writeln([Object obj = ""]) { | 457 void writeln([Object obj = ""]) { |
| 458 if (!_headersWritten) _dataSink.encoding = encoding; |
456 _dataSink.writeln(obj); | 459 _dataSink.writeln(obj); |
457 } | 460 } |
458 | 461 |
459 void writeCharCode(int charCode) { | 462 void writeCharCode(int charCode) { |
| 463 if (!_headersWritten) _dataSink.encoding = encoding; |
460 _dataSink.writeCharCode(charCode); | 464 _dataSink.writeCharCode(charCode); |
461 } | 465 } |
462 | 466 |
463 void add(List<int> data) { | 467 void add(List<int> data) { |
464 if (data.length == 0) return; | 468 if (data.length == 0) return; |
465 _dataSink.add(data); | 469 _dataSink.add(data); |
466 } | 470 } |
467 | 471 |
468 void addError(error, [StackTrace stackTrace]) { | 472 void addError(error, [StackTrace stackTrace]) { |
469 _dataSink.addError(error, stackTrace); | 473 _dataSink.addError(error, stackTrace); |
(...skipping 2107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2577 | 2581 |
2578 String _getHttpVersion() { | 2582 String _getHttpVersion() { |
2579 var version = Platform.version; | 2583 var version = Platform.version; |
2580 // Only include major and minor version numbers. | 2584 // Only include major and minor version numbers. |
2581 int index = version.indexOf('.', version.indexOf('.') + 1); | 2585 int index = version.indexOf('.', version.indexOf('.') + 1); |
2582 version = version.substring(0, index); | 2586 version = version.substring(0, index); |
2583 return 'Dart/$version (dart:io)'; | 2587 return 'Dart/$version (dart:io)'; |
2584 } | 2588 } |
2585 | 2589 |
2586 | 2590 |
OLD | NEW |