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

Unified Diff: pkg/http/lib/src/io_client.dart

Issue 810223002: Remove the http package from the repo. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 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 side-by-side diff with in-line comments
Download patch
Index: pkg/http/lib/src/io_client.dart
diff --git a/pkg/http/lib/src/io_client.dart b/pkg/http/lib/src/io_client.dart
deleted file mode 100644
index 1114180cba763c3cb01d0652d28e16edec81e5a4..0000000000000000000000000000000000000000
--- a/pkg/http/lib/src/io_client.dart
+++ /dev/null
@@ -1,88 +0,0 @@
-// Copyright (c) 2012, 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.
-
-library io_client;
-
-import 'dart:async';
-
-import 'package:stack_trace/stack_trace.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;
-
- /// 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();
- }
- }
-
- /// Sends an HTTP request and asynchronously returns the response.
- Future<StreamedResponse> send(BaseRequest request) {
- var stream = request.finalize();
-
- return Chain.track(_inner.openUrl(request.method, request.url))
- .then((ioRequest) {
- var contentLength = request.contentLength == null ?
- -1 : request.contentLength;
- ioRequest
- ..followRedirects = request.followRedirects
- ..maxRedirects = request.maxRedirects
- ..contentLength = contentLength
- ..persistentConnection = request.persistentConnection;
- request.headers.forEach((name, value) {
- ioRequest.headers.set(name, value);
- });
- return Chain.track(stream.pipe(ioRequest));
- }).then((response) {
- var headers = {};
- response.headers.forEach((key, values) {
- headers[key] = values.join(',');
- });
-
- var contentLength = response.contentLength == -1 ?
- null : response.contentLength;
- return new StreamedResponse(
- response.handleError((error) =>
- throw new ClientException(error.message, error.uri),
- test: (error) => io.isHttpException(error)),
- response.statusCode,
- contentLength: contentLength,
- request: request,
- headers: headers,
- isRedirect: response.isRedirect,
- persistentConnection: response.persistentConnection,
- reasonPhrase: response.reasonPhrase);
- }).catchError((error) {
- if (!io.isHttpException(error)) throw error;
- throw new ClientException(error.message, error.uri);
- });
- }
-
- /// Closes the client. This terminates all active connections. If a client
- /// remains unclosed, the Dart process may not terminate.
- void close() {
- if (_inner != null) _inner.close(force: true);
- _inner = null;
- }
-}
« no previous file with comments | « pkg/http/lib/src/io.dart ('k') | pkg/http/lib/src/mock_client.dart » ('j') | pkg/pkg.gyp » ('J')

Powered by Google App Engine
This is Rietveld 408576698