-
Notifications
You must be signed in to change notification settings - Fork 382
Stop using dart:mirrors. #55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
## 0.11.3+10 | ||
|
||
* Stop using `dart:mirrors`. | ||
|
||
## 0.11.3+9 | ||
|
||
* Remove an extra newline in multipart chunks. | ||
|
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,37 +3,24 @@ | |
// BSD-style license that can be found in the LICENSE file. | ||
|
||
import 'dart:async'; | ||
import 'dart:io'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this mean "package:http/http.dart" can only be imported on the command line VM? If so, isn't that a breaking change? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As of 1.22, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What?! Where was that announced? It's not in the CHANGELOG. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's a @dgrove question. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is the change to dart:io for 1.22 or 1.23? (I heard it was 1.23.) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have a fix out as #58 |
||
|
||
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. | ||
/// | ||
/// 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 @@ class IOClient extends BaseClient { | |
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 @@ class IOClient extends BaseClient { | |
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); | ||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
name: http | ||
version: 0.11.3+9 | ||
version: 0.11.3+10 | ||
author: "Dart Team <[email protected]>" | ||
homepage: https://github.com/dart-lang/http | ||
description: A composable, Future-based API for making HTTP requests. | ||
|
@@ -12,4 +12,4 @@ dependencies: | |
dev_dependencies: | ||
unittest: ">=0.9.0 <0.12.0" | ||
environment: | ||
sdk: ">=1.9.0 <2.0.0" | ||
sdk: ">=1.22.0 <2.0.0" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment isn't relevant anymore, since you can't import this library without "dart:io" being available, can you?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It can now be importable while also being unavailable in the sense that its API just throws
UnsupportedError
s.