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

Side by Side Diff: pkg/shelf/test/shelf_io_test.dart

Issue 227563010: pkg/shelf: case-insensitive headers, cleaner Request ctor, a lot more tests (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 8 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
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 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 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. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library shelf_io_test; 5 library shelf_io_test;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:convert'; 8 import 'dart:convert';
9 import 'dart:io'; 9 import 'dart:io';
10 10
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 122
123 return _scheduleGet().then((response) { 123 return _scheduleGet().then((response) {
124 expect(response.statusCode, 299); 124 expect(response.statusCode, 299);
125 expect(response.body, 'Hello from /'); 125 expect(response.body, 'Hello from /');
126 }); 126 });
127 }); 127 });
128 128
129 test('custom request headers are received by the handler', () { 129 test('custom request headers are received by the handler', () {
130 _scheduleServer((request) { 130 _scheduleServer((request) {
131 expect(request.headers, containsPair('custom-header', 'client value')); 131 expect(request.headers, containsPair('custom-header', 'client value'));
132
133 // dart:io HttpServer splits multi-value headers into an array
134 // validate that they are combined correctly
135 expect(request.headers, containsPair('multi-header', 'foo,bar,baz'));
132 return syncHandler(request); 136 return syncHandler(request);
133 }); 137 });
134 138
135 var headers = { 139 var headers = {
136 'custom-header': 'client value' 140 'custom-header': 'client value',
141 'multi-header': 'foo,bar,baz'
nweiz 2014/04/08 20:23:09 Does dart:io really split comma-separated header v
kevmoo 2014/04/08 21:41:13 HttpHeaders stores values in a List. shelf_io does
137 }; 142 };
138 143
139 return _scheduleGet(headers: headers).then((response) { 144 return _scheduleGet(headers: headers).then((response) {
140 expect(response.statusCode, HttpStatus.OK); 145 expect(response.statusCode, HttpStatus.OK);
141 expect(response.body, 'Hello from /'); 146 expect(response.body, 'Hello from /');
142 }); 147 });
143 }); 148 });
144 149
145 test('post with empty content', () { 150 test('post with empty content', () {
146 _scheduleServer((request) { 151 _scheduleServer((request) {
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 213
209 var request = new http.Request('POST', 214 var request = new http.Request('POST',
210 Uri.parse('http://localhost:$_serverPort/')); 215 Uri.parse('http://localhost:$_serverPort/'));
211 216
212 if (headers != null) request.headers.addAll(headers); 217 if (headers != null) request.headers.addAll(headers);
213 if (body != null) request.body = body; 218 if (body != null) request.body = body;
214 219
215 return request.send(); 220 return request.send();
216 }); 221 });
217 } 222 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698