Removed uses of Chain.track
R=nweiz@google.com
Review URL: https://codereview.chromium.org//1306723008 .
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 3b77fae..cf14742 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,9 @@
+## 0.11.3+2
+
+* Require Dart SDK >= 1.9.0
+
+* Eliminate many uses of `Chain.track` from the `stack_trace` package.
+
## 0.11.3+1
* Support `http_parser` 1.0.0.
diff --git a/lib/src/base_client.dart b/lib/src/base_client.dart
index ad85a67..104d702 100644
--- a/lib/src/base_client.dart
+++ b/lib/src/base_client.dart
@@ -14,7 +14,6 @@
import 'request.dart';
import 'response.dart';
import 'streamed_response.dart';
-import 'utils.dart';
/// The abstract base class for an HTTP client. This is a mixin-style class;
/// subclasses only need to implement [send] and maybe [close], and then they
@@ -150,27 +149,26 @@
/// Sends a non-streaming [Request] and returns a non-streaming [Response].
Future<Response> _sendUnstreamed(String method, url,
- Map<String, String> headers, [body, Encoding encoding]) {
- return syncFuture(() {
- if (url is String) url = Uri.parse(url);
- var request = new Request(method, url);
+ Map<String, String> headers, [body, Encoding encoding]) async {
- if (headers != null) request.headers.addAll(headers);
- if (encoding != null) request.encoding = encoding;
- if (body != null) {
- if (body is String) {
- request.body = body;
- } else if (body is List) {
- request.bodyBytes = body;
- } else if (body is Map) {
- request.bodyFields = body;
- } else {
- throw new ArgumentError('Invalid request body "$body".');
- }
+ if (url is String) url = Uri.parse(url);
+ var request = new Request(method, url);
+
+ if (headers != null) request.headers.addAll(headers);
+ if (encoding != null) request.encoding = encoding;
+ if (body != null) {
+ if (body is String) {
+ request.body = body;
+ } else if (body is List) {
+ request.bodyBytes = body;
+ } else if (body is Map) {
+ request.bodyFields = body;
+ } else {
+ throw new ArgumentError('Invalid request body "$body".');
}
+ }
- return send(request);
- }).then(Response.fromStream);
+ return Response.fromStream(await send(request));
}
/// Throws an error if [response] is not successful.
diff --git a/lib/src/io_client.dart b/lib/src/io_client.dart
index 1114180..78d7175 100644
--- a/lib/src/io_client.dart
+++ b/lib/src/io_client.dart
@@ -6,8 +6,6 @@
import 'dart:async';
-import 'package:stack_trace/stack_trace.dart';
-
import 'base_client.dart';
import 'base_request.dart';
import 'exception.dart';
@@ -41,7 +39,7 @@
Future<StreamedResponse> send(BaseRequest request) {
var stream = request.finalize();
- return Chain.track(_inner.openUrl(request.method, request.url))
+ return _inner.openUrl(request.method, request.url)
.then((ioRequest) {
var contentLength = request.contentLength == null ?
-1 : request.contentLength;
@@ -53,7 +51,7 @@
request.headers.forEach((name, value) {
ioRequest.headers.set(name, value);
});
- return Chain.track(stream.pipe(ioRequest));
+ return stream.pipe(ioRequest);
}).then((response) {
var headers = {};
response.headers.forEach((key, values) {
diff --git a/lib/src/multipart_file.dart b/lib/src/multipart_file.dart
index 07758b9..9e40c64 100644
--- a/lib/src/multipart_file.dart
+++ b/lib/src/multipart_file.dart
@@ -9,7 +9,6 @@
import 'package:http_parser/http_parser.dart';
import 'package:path/path.dart' as path;
-import 'package:stack_trace/stack_trace.dart';
import 'byte_stream.dart';
import 'io.dart' as io;
@@ -93,8 +92,8 @@
io.assertSupported("MultipartFile.fromPath");
if (filename == null) filename = path.basename(filePath);
var file = io.newFile(filePath);
- return Chain.track(file.length()).then((length) {
- var stream = new ByteStream(Chain.track(file.openRead()));
+ return file.length().then((length) {
+ var stream = new ByteStream(file.openRead());
return new MultipartFile(field, stream, length,
filename: filename,
contentType: contentType);
diff --git a/lib/src/utils.dart b/lib/src/utils.dart
index 8aa7d49..9d2db3d 100644
--- a/lib/src/utils.dart
+++ b/lib/src/utils.dart
@@ -8,8 +8,6 @@
import 'dart:convert';
import 'dart:typed_data';
-import 'package:stack_trace/stack_trace.dart';
-
import 'byte_stream.dart';
/// Converts a URL query string (or `application/x-www-form-urlencoded` body)
@@ -196,6 +194,3 @@
void chainToCompleter(Future future, Completer completer) {
future.then(completer.complete, onError: completer.completeError);
}
-
-/// Like [Future.sync], but wraps the Future in [Chain.track] as well.
-Future syncFuture(callback()) => Chain.track(new Future.sync(callback));
diff --git a/pubspec.yaml b/pubspec.yaml
index a4a556f..9efca2c 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -1,5 +1,5 @@
name: http
-version: 0.11.3+1
+version: 0.11.3+2
author: "Dart Team <misc@dartlang.org>"
homepage: https://github.com/dart-lang/http
description: A composable, Future-based API for making HTTP requests.
@@ -10,4 +10,4 @@
dev_dependencies:
unittest: ">=0.9.0 <0.12.0"
environment:
- sdk: ">=1.1.0 <2.0.0"
+ sdk: ">=1.9.0 <2.0.0"