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

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

Issue 11414195: Make #maxRedirects and #followRedirects work for the dart:io HTTP client. (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/test/request_test.dart » ('j') | pkg/http/test/request_test.dart » ('J')
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 io_client; 5 library io_client;
6 6
7 import 'dart:io'; 7 import 'dart:io';
8 8
9 import 'base_client.dart'; 9 import 'base_client.dart';
10 import 'base_request.dart'; 10 import 'base_request.dart';
11 import 'streamed_response.dart'; 11 import 'streamed_response.dart';
12 import 'utils.dart'; 12 import 'utils.dart';
13 13
14 /// A `dart:io`-based HTTP client. This is the default client. 14 /// A `dart:io`-based HTTP client. This is the default client.
15 class IOClient extends BaseClient { 15 class IOClient extends BaseClient {
16 /// The underlying `dart:io` HTTP client. 16 /// The underlying `dart:io` HTTP client.
17 HttpClient _inner; 17 HttpClient _inner;
18 18
19 /// Creates a new HTTP client. 19 /// Creates a new HTTP client.
20 IOClient() : _inner = new HttpClient(); 20 IOClient() : _inner = new HttpClient();
21 21
22 /// Sends an HTTP request and asynchronously returns the response. 22 /// Sends an HTTP request and asynchronously returns the response.
23 Future<StreamedResponse> send(BaseRequest request) { 23 Future<StreamedResponse> send(BaseRequest request) {
24 var stream = request.finalize(); 24 var stream = request.finalize();
25 25
26 var completer = new Completer<StreamedResponse>(); 26 var completer = new Completer<StreamedResponse>();
27 var connection = _inner.openUrl(request.method, request.url); 27 var connection = _inner.openUrl(request.method, request.url);
28 connection.followRedirects = request.followRedirects;
29 connection.maxRedirects = request.maxRedirects;
28 connection.onError = (e) { 30 connection.onError = (e) {
29 async.then((_) { 31 async.then((_) {
30 // TODO(nweiz): remove this when issue 4974 is fixed 32 // TODO(nweiz): remove this when issue 4974 is fixed
31 if (completer.future.isComplete) throw e; 33 if (completer.future.isComplete) throw e;
32 34
33 completer.completeException(e); 35 completer.completeException(e);
34 }); 36 });
35 }; 37 };
36 38
37 connection.onRequest = (underlyingRequest) { 39 connection.onRequest = (underlyingRequest) {
(...skipping 27 matching lines...) Expand all
65 return completer.future; 67 return completer.future;
66 } 68 }
67 69
68 /// Closes the client. This terminates all active connections. If a client 70 /// Closes the client. This terminates all active connections. If a client
69 /// remains unclosed, the Dart process may not terminate. 71 /// remains unclosed, the Dart process may not terminate.
70 void close() { 72 void close() {
71 if (_inner != null) _inner.shutdown(); 73 if (_inner != null) _inner.shutdown();
72 _inner = null; 74 _inner = null;
73 } 75 }
74 } 76 }
OLDNEW
« no previous file with comments | « no previous file | pkg/http/test/request_test.dart » ('j') | pkg/http/test/request_test.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698