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

Side by Side Diff: dart/pkg/http_base/lib/http_base_io.dart

Issue 495533003: Remove obsolete http_base package (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 3 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 | « dart/pkg/http_base/lib/http_base_html.dart ('k') | dart/pkg/http_base/pubspec.yaml » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 library http_base.http_base_io;
2
3 import 'dart:io' as io;
4 import 'dart:async';
5
6 import 'http_base.dart';
7 export 'http_base.dart';
8
9 /// An implementation for [RequestHandler]. It uses dart:io to make http
10 /// requests.
11 class Client {
12 // TODO: Should we provide a mechanism to close (forcefully or not) [_client]?
13 final io.HttpClient _client = new io.HttpClient();
14
15 Future<Response> call(Request request) {
16 return _client.openUrl(request.method, request.url).then((ioRequest) {
17 // TODO: Special case Cookie/Set-Cookie here!
18
19 for (var name in request.headers.names) {
20 ioRequest.headers.set(name, request.headers[name]);
21 }
22
23 var stream = request.read();
24 return ioRequest.addStream(stream).then((_) {
25 return ioRequest.close();
26 });
27 }).then((io.HttpClientResponse ioResponse) {
28 var headerMap = {};
29 ioResponse.headers.forEach((name, values) {
30 headerMap[name] = values;
31 });
32 var headers = new HeadersImpl(headerMap);
33
34 return new ResponseImpl(
35 ioResponse.statusCode, headers: headers, body: ioResponse);
36 });
37 }
38 }
OLDNEW
« no previous file with comments | « dart/pkg/http_base/lib/http_base_html.dart ('k') | dart/pkg/http_base/pubspec.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698