Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(180)

Side by Side Diff: sdk/lib/io/http_impl.dart

Issue 262433003: Add writeHeaders argument to HttpResponse::detachSocket. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: fix comment. Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « sdk/lib/io/http.dart ('k') | tests/standalone/io/http_detach_socket_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 }
OLDNEW
« no previous file with comments | « sdk/lib/io/http.dart ('k') | tests/standalone/io/http_detach_socket_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698