| 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 _OUTGOING_BUFFER_SIZE = 8 * 1024; | 7 const int _OUTGOING_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 508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 519 _reasonPhrase = reasonPhrase; | 519 _reasonPhrase = reasonPhrase; |
| 520 } | 520 } |
| 521 | 521 |
| 522 Future redirect(Uri location, {int status: HttpStatus.MOVED_TEMPORARILY}) { | 522 Future redirect(Uri location, {int status: HttpStatus.MOVED_TEMPORARILY}) { |
| 523 if (_outgoing.headersWritten) throw new StateError("Header already sent"); | 523 if (_outgoing.headersWritten) throw new StateError("Header already sent"); |
| 524 statusCode = status; | 524 statusCode = status; |
| 525 headers.set("location", location.toString()); | 525 headers.set("location", location.toString()); |
| 526 return close(); | 526 return close(); |
| 527 } | 527 } |
| 528 | 528 |
| 529 Future<Socket> detachSocket() { | 529 Future<Socket> detachSocket({bool writeHeaders: true}) { |
| 530 if (_outgoing.headersWritten) throw new StateError("Headers already sent"); | 530 if (_outgoing.headersWritten) throw new StateError("Headers already sent"); |
| 531 deadline = null; // Be sure to stop any deadline. | 531 deadline = null; // Be sure to stop any deadline. |
| 532 var future = _httpRequest._httpConnection.detachSocket(); | 532 var future = _httpRequest._httpConnection.detachSocket(); |
| 533 var headersFuture = _outgoing.writeHeaders(drainRequest: false, | 533 if (writeHeaders) { |
| 534 setOutgoing: false); | 534 var headersFuture = _outgoing.writeHeaders(drainRequest: false, |
| 535 assert(headersFuture == null); | 535 setOutgoing: false); |
| 536 assert(headersFuture == null); |
| 537 } else { |
| 538 // Imitate having written the headers. |
| 539 _outgoing.headersWritten = true; |
| 540 } |
| 536 // Close connection so the socket is 'free'. | 541 // Close connection so the socket is 'free'. |
| 537 close(); | 542 close(); |
| 538 done.catchError((_) { | 543 done.catchError((_) { |
| 539 // Catch any error on done, as they automatically will be | 544 // Catch any error on done, as they automatically will be |
| 540 // propagated to the websocket. | 545 // propagated to the websocket. |
| 541 }); | 546 }); |
| 542 return future; | 547 return future; |
| 543 } | 548 } |
| 544 | 549 |
| 545 HttpConnectionInfo get connectionInfo => _httpRequest.connectionInfo; | 550 HttpConnectionInfo get connectionInfo => _httpRequest.connectionInfo; |
| (...skipping 2070 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2616 const _RedirectInfo(this.statusCode, this.method, this.location); | 2621 const _RedirectInfo(this.statusCode, this.method, this.location); |
| 2617 } | 2622 } |
| 2618 | 2623 |
| 2619 String _getHttpVersion() { | 2624 String _getHttpVersion() { |
| 2620 var version = Platform.version; | 2625 var version = Platform.version; |
| 2621 // Only include major and minor version numbers. | 2626 // Only include major and minor version numbers. |
| 2622 int index = version.indexOf('.', version.indexOf('.') + 1); | 2627 int index = version.indexOf('.', version.indexOf('.') + 1); |
| 2623 version = version.substring(0, index); | 2628 version = version.substring(0, index); |
| 2624 return 'Dart/$version (dart:io)'; | 2629 return 'Dart/$version (dart:io)'; |
| 2625 } | 2630 } |
| OLD | NEW |