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

Side by Side Diff: pkg/http/lib/src/base_request.dart

Issue 11434018: Make pkg/http use HttpClient.shutdown(force: true). (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years 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 | « no previous file | pkg/http/lib/src/io_client.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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 library base_request; 5 library base_request;
6 6
7 import 'dart:io'; 7 import 'dart:io';
8 import 'dart:isolate';
8 import 'dart:uri'; 9 import 'dart:uri';
9 10
10 import 'client.dart'; 11 import 'client.dart';
11 import 'streamed_response.dart'; 12 import 'streamed_response.dart';
12 13
13 /// The base class for HTTP requests. 14 /// The base class for HTTP requests.
14 /// 15 ///
15 /// Subclasses of [BaseRequest] can be constructed manually and passed to 16 /// Subclasses of [BaseRequest] can be constructed manually and passed to
16 /// [BaseClient.send], which allows the user to provide fine-grained control 17 /// [BaseClient.send], which allows the user to provide fine-grained control
17 /// over the request properties. However, usually it's easier to use convenience 18 /// over the request properties. However, usually it's easier to use convenience
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 } 98 }
98 99
99 /// Sends this request. 100 /// Sends this request.
100 /// 101 ///
101 /// This automatically initializes a new [Client] and closes that client once 102 /// This automatically initializes a new [Client] and closes that client once
102 /// the request is complete. If you're planning on making multiple requests to 103 /// the request is complete. If you're planning on making multiple requests to
103 /// the same server, you should use a single [Client] for all of those 104 /// the same server, you should use a single [Client] for all of those
104 /// requests. 105 /// requests.
105 Future<StreamedResponse> send() { 106 Future<StreamedResponse> send() {
106 var client = new Client(); 107 var client = new Client();
107 var future = client.send(this); 108 return client.send(this).transform((response) {
108 future.onComplete((_) => client.close()); 109 // TODO(nweiz): This makes me sick to my stomach, but it's currently the
109 return future; 110 // best way to listen for the response stream being closed. Kill it with
111 // fire once issue 4202 is fixed.
112 new Timer.repeating(100, (timer) {
113 if (response.stream.closed) {
114 client.close();
115 timer.cancel();
116 }
117 });
118
119 return response;
120 });
110 } 121 }
111 122
112 /// Throws an error if this request has been finalized. 123 /// Throws an error if this request has been finalized.
113 void _checkFinalized() { 124 void _checkFinalized() {
114 if (!finalized) return; 125 if (!finalized) return;
115 throw new StateError("Can't modify a finalized Request."); 126 throw new StateError("Can't modify a finalized Request.");
116 } 127 }
117 } 128 }
OLDNEW
« no previous file with comments | « no previous file | pkg/http/lib/src/io_client.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698