Stop using dart:mirrors. (#55)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index bb02985..3e4ebd8 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,7 @@
+## 0.11.3+10
+
+* Stop using `dart:mirrors`.
+
 ## 0.11.3+9
 
 * Remove an extra newline in multipart chunks.
diff --git a/lib/browser_client.dart b/lib/browser_client.dart
index 883b2b1..309b3ac 100644
--- a/lib/browser_client.dart
+++ b/lib/browser_client.dart
@@ -15,9 +15,7 @@
 import 'src/streamed_response.dart';
 
 // TODO(nweiz): Move this under src/, re-export from lib/http.dart, and use this
-// automatically from [new Client] once we can create an HttpRequest using
-// mirrors on dart2js (issue 18541) and dart2js doesn't crash on pkg/collection
-// (issue 18535).
+// automatically from [new Client] once sdk#24581 is fixed.
 
 /// A `dart:html`-based HTTP client that runs in the browser and is backed by
 /// XMLHttpRequests.
diff --git a/lib/src/client.dart b/lib/src/client.dart
index 70d317e..cf1ff78 100644
--- a/lib/src/client.dart
+++ b/lib/src/client.dart
@@ -8,7 +8,6 @@
 
 import 'base_client.dart';
 import 'base_request.dart';
-import 'io.dart' as io;
 import 'io_client.dart';
 import 'response.dart';
 import 'streamed_response.dart';
@@ -28,10 +27,7 @@
   /// Currently this will create an [IOClient] if `dart:io` is available and
   /// throw an [UnsupportedError] otherwise. In the future, it will create a
   /// [BrowserClient] if `dart:html` is available.
-  factory Client() {
-    io.assertSupported("IOClient");
-    return new IOClient();
-  }
+  factory Client() => new IOClient();
 
   /// Sends an HTTP HEAD request with the given headers to the given URL, which
   /// can be a [Uri] or a [String].
diff --git a/lib/src/io.dart b/lib/src/io.dart
deleted file mode 100644
index 7c41f99..0000000
--- a/lib/src/io.dart
+++ /dev/null
@@ -1,55 +0,0 @@
-// Copyright (c) 2014, the Dart project authors.  Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-@MirrorsUsed(targets: const ['dart.io.HttpClient', 'dart.io.HttpException',
-  'dart.io.File'])
-import 'dart:mirrors';
-
-/// Whether `dart:io` is supported on this platform.
-bool get supported => _library != null;
-
-/// The `dart:io` library mirror, or `null` if it couldn't be loaded.
-final _library = _getLibrary();
-
-/// The `dart:io` HttpClient class mirror.
-final ClassMirror _httpClient =
-    _library.declarations[const Symbol('HttpClient')];
-
-/// The `dart:io` HttpException class mirror.
-final ClassMirror _httpException =
-    _library.declarations[const Symbol('HttpException')];
-
-/// The `dart:io` File class mirror.
-final ClassMirror _file = _library.declarations[const Symbol('File')];
-
-/// Asserts that the [name]d `dart:io` feature is supported on this platform.
-///
-/// If `dart:io` doesn't work on this platform, this throws an
-/// [UnsupportedError].
-void assertSupported(String name) {
-  if (supported) return;
-  throw new UnsupportedError("$name isn't supported on this platform.");
-}
-
-/// Creates a new `dart:io` HttpClient instance.
-newHttpClient() => _httpClient.newInstance(const Symbol(''), []).reflectee;
-
-/// Creates a new `dart:io` File instance with the given [path].
-newFile(String path) => _file.newInstance(const Symbol(''), [path]).reflectee;
-
-/// Returns whether [error] is a `dart:io` HttpException.
-bool isHttpException(error) => reflect(error).type.isSubtypeOf(_httpException);
-
-/// Returns whether [client] is a `dart:io` HttpClient.
-bool isHttpClient(client) => reflect(client).type.isSubtypeOf(_httpClient);
-
-/// Tries to load `dart:io` and returns `null` if it fails.
-LibraryMirror _getLibrary() {
-  try {
-    return currentMirrorSystem().findLibrary(const Symbol('dart.io'));
-  } catch (_) {
-    // TODO(nweiz): narrow the catch clause when issue 18532 is fixed.
-    return null;
-  }
-}
diff --git a/lib/src/io_client.dart b/lib/src/io_client.dart
index 7387a30..03950ad 100644
--- a/lib/src/io_client.dart
+++ b/lib/src/io_client.dart
@@ -3,13 +3,13 @@
 // BSD-style license that can be found in the LICENSE file.
 
 import 'dart:async';
+import 'dart:io';
 
 import 'package:async/async.dart';
 
 import 'base_client.dart';
 import 'base_request.dart';
 import 'exception.dart';
-import 'io.dart' as io;
 import 'streamed_response.dart';
 
 /// A `dart:io`-based HTTP client.
@@ -17,23 +17,10 @@
 /// This is the default client when running on the command line.
 class IOClient extends BaseClient {
   /// The underlying `dart:io` HTTP client.
-  var _inner;
+  HttpClient _inner;
 
   /// Creates a new HTTP client.
-  ///
-  /// [innerClient] must be a `dart:io` HTTP client. If it's not passed, a
-  /// default one will be instantiated.
-  IOClient([innerClient]) {
-    io.assertSupported("IOClient");
-    if (innerClient != null) {
-      // TODO(nweiz): remove this assert when we can type [innerClient]
-      // properly.
-      assert(io.isHttpClient(innerClient));
-      _inner = innerClient;
-    } else {
-      _inner = io.newHttpClient();
-    }
-  }
+  IOClient([HttpClient inner]) : _inner = inner ?? new HttpClient();
 
   /// Sends an HTTP request and asynchronously returns the response.
   Future<StreamedResponse> send(BaseRequest request) async {
@@ -63,7 +50,7 @@
       return new StreamedResponse(
           DelegatingStream.typed/*<List<int>>*/(response).handleError((error) =>
               throw new ClientException(error.message, error.uri),
-              test: (error) => io.isHttpException(error)),
+              test: (error) => error is HttpException),
           response.statusCode,
           contentLength: response.contentLength == -1
               ? null
@@ -73,8 +60,7 @@
           isRedirect: response.isRedirect,
           persistentConnection: response.persistentConnection,
           reasonPhrase: response.reasonPhrase);
-    } catch (error) {
-      if (!io.isHttpException(error)) rethrow;
+    } on HttpException catch (error) {
       throw new ClientException(error.message, error.uri);
     }
   }
diff --git a/lib/src/multipart_file.dart b/lib/src/multipart_file.dart
index 3597c6e..da4bfac 100644
--- a/lib/src/multipart_file.dart
+++ b/lib/src/multipart_file.dart
@@ -4,13 +4,13 @@
 
 import 'dart:async';
 import 'dart:convert';
+import 'dart:io';
 
 import 'package:async/async.dart';
 import 'package:http_parser/http_parser.dart';
 import 'package:path/path.dart' as path;
 
 import 'byte_stream.dart';
-import 'io.dart' as io;
 import 'utils.dart';
 
 /// A file to be uploaded as part of a [MultipartRequest]. This doesn't need to
@@ -85,12 +85,12 @@
   /// defaults to `application/octet-stream`, but in the future may be inferred
   /// from [filename].
   ///
-  /// This can only be used in an environment that supports "dart:io".
+  /// Throws an [UnsupportedError] if `dart:io` isn't supported in this
+  /// environment.
   static Future<MultipartFile> fromPath(String field, String filePath,
       {String filename, MediaType contentType}) async {
-    io.assertSupported("MultipartFile.fromPath");
     if (filename == null) filename = path.basename(filePath);
-    var file = io.newFile(filePath);
+    var file = new File(filePath);
     var length = await file.length();
     var stream = new ByteStream(DelegatingStream.typed(file.openRead()));
     return new MultipartFile(field, stream, length,
diff --git a/pubspec.yaml b/pubspec.yaml
index 4aa69c1..4ae55d8 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -1,5 +1,5 @@
 name: http
-version: 0.11.3+9
+version: 0.11.3+10
 author: "Dart Team <misc@dartlang.org>"
 homepage: https://github.com/dart-lang/http
 description: A composable, Future-based API for making HTTP requests.
@@ -12,4 +12,4 @@
 dev_dependencies:
   unittest: ">=0.9.0 <0.12.0"
 environment:
-  sdk: ">=1.9.0 <2.0.0"
+  sdk: ">=1.22.0 <2.0.0"