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

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

Issue 299483002: Support a user-supplied dart:io client in pkg/http. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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 | « pkg/http/CHANGELOG.md ('k') | 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) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 http.io; 5 library http.io;
6 6
7 @MirrorsUsed(targets: const ['dart.io.HttpClient', 'dart.io.HttpException', 7 @MirrorsUsed(targets: const ['dart.io.HttpClient', 'dart.io.HttpException',
8 'dart.io.File']) 8 'dart.io.File'])
9 import 'dart:mirrors'; 9 import 'dart:mirrors';
10 10
(...skipping 25 matching lines...) Expand all
36 36
37 /// Creates a new `dart:io` HttpClient instance. 37 /// Creates a new `dart:io` HttpClient instance.
38 newHttpClient() => _httpClient.newInstance(const Symbol(''), []).reflectee; 38 newHttpClient() => _httpClient.newInstance(const Symbol(''), []).reflectee;
39 39
40 /// Creates a new `dart:io` File instance with the given [path]. 40 /// Creates a new `dart:io` File instance with the given [path].
41 newFile(String path) => _file.newInstance(const Symbol(''), [path]).reflectee; 41 newFile(String path) => _file.newInstance(const Symbol(''), [path]).reflectee;
42 42
43 /// Returns whether [error] is a `dart:io` HttpException. 43 /// Returns whether [error] is a `dart:io` HttpException.
44 bool isHttpException(error) => reflect(error).type.isSubtypeOf(_httpException); 44 bool isHttpException(error) => reflect(error).type.isSubtypeOf(_httpException);
45 45
46 /// Returns whether [client] is a `dart:io` HttpClient.
47 bool isHttpClient(client) => reflect(client).type.isSubtypeOf(_httpClient);
48
46 /// Tries to load `dart:io` and returns `null` if it fails. 49 /// Tries to load `dart:io` and returns `null` if it fails.
47 LibraryMirror _getLibrary() { 50 LibraryMirror _getLibrary() {
48 try { 51 try {
49 return currentMirrorSystem().findLibrary(const Symbol('dart.io')); 52 return currentMirrorSystem().findLibrary(const Symbol('dart.io'));
50 } catch (_) { 53 } catch (_) {
51 // TODO(nweiz): narrow the catch clause when issue 18532 is fixed. 54 // TODO(nweiz): narrow the catch clause when issue 18532 is fixed.
52 return null; 55 return null;
53 } 56 }
54 } 57 }
OLDNEW
« no previous file with comments | « pkg/http/CHANGELOG.md ('k') | pkg/http/lib/src/io_client.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698