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

Side by Side Diff: pkg/http/test/io/streamed_request_test.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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file.
4
5 library http.test.io.streamed_request_test;
6
7 import 'dart:convert';
8
9 import 'package:http/http.dart' as http;
10 import 'package:unittest/unittest.dart';
11
12 import 'utils.dart';
13
14 void main() {
15 group('contentLength', () {
16 test('controls the Content-Length header', () {
17 return startServer().then((_) {
18 var request = new http.StreamedRequest('POST', serverUrl);
19 request.contentLength = 10;
20 request.sink.add([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);
21 request.sink.close();
22
23 return request.send();
24 }).then((response) {
25 expect(UTF8.decodeStream(response.stream),
26 completion(parse(containsPair('headers',
27 containsPair('content-length', ['10'])))));
28 }).whenComplete(stopServer);
29 });
30
31 test('defaults to sending no Content-Length', () {
32 return startServer().then((_) {
33 var request = new http.StreamedRequest('POST', serverUrl);
34 request.sink.add([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);
35 request.sink.close();
36
37 return request.send();
38 }).then((response) {
39 expect(UTF8.decodeStream(response.stream),
40 completion(parse(containsPair('headers',
41 isNot(contains('content-length'))))));
42 }).whenComplete(stopServer);
43 });
44 });
45
46 // Regression test.
47 test('.send() with a response with no content length', () {
48 return startServer().then((_) {
49 var request = new http.StreamedRequest(
50 'GET', serverUrl.resolve('/no-content-length'));
51 request.sink.close();
52 return request.send();
53 }).then((response) {
54 expect(UTF8.decodeStream(response.stream), completion(equals('body')));
55 }).whenComplete(stopServer);
56 });
57
58 }
OLDNEW
« no previous file with comments | « pkg/http/test/io/request_test.dart ('k') | pkg/http/test/io/utils.dart » ('j') | pkg/pkg.gyp » ('J')

Powered by Google App Engine
This is Rietveld 408576698