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

Side by Side Diff: dart/pkg/http_base/test/http_base_io_test.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
OLDNEW
(Empty)
1 library http_base.http_base_io_test;
2
3 import 'dart:async';
4 import 'dart:io';
5 import 'dart:convert';
6
7 import 'package:http_base/http_base_io.dart';
8 import 'package:unittest/unittest.dart';
9
10 main() {
11 test('io-client', () {
12 HttpServer.bind('127.0.0.1', 0).then(expectAsync((HttpServer server) {
13 server.first.then(expectAsync((request) {
14 expect(request.method, equals('POST'));
15 expect(request.headers.value('foo'), equals('bar'));
16
17 return request.fold([], (buf, data) => buf..addAll(data)).then((data) {
18 request
19 ..response.statusCode = 201
20 ..response.headers.set('foo', ['foo', 'bar'])
21 ..response.add(data)
22 ..response.close();
23 });
24 })).whenComplete(() => server.close());
25
26 var client = new Client();
27 var uri = Uri.parse('http://127.0.0.1:${server.port}/');
28 var headers = new HeadersImpl({'foo' : 'bar'});
29 var body = (new StreamController()
30 ..add(UTF8.encode('my-data'))
31 ..close()).stream;
32
33 var request = new RequestImpl('POST', uri, headers: headers, body: body);
34 client(request).then(expectAsync((response) {
35 expect(response.statusCode, equals(201));
36 // NOTE: dart:io joins multiple values with ", ".
37 expect(response.headers['foo'], equals('foo, bar'));
38 expect(response.headers.getMultiple('foo').toList(),
39 equals(['foo','bar']));
40
41 response.read()
42 .transform(UTF8.decoder).join('').then(expectAsync((data) {
43 expect(data, equals('my-data'));
44 }));
45 }));
46 }));
47 });
48 }
OLDNEW
« no previous file with comments | « dart/pkg/http_base/test/http_base_html_test.dart ('k') | dart/pkg/http_base/test/http_base_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698