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

Side by Side Diff: pkg/http_server/test/virtual_directory_test.dart

Issue 17581002: Add new VirtualHost class to http_server package, for handling multiple hosts on multiple sources (… (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Add cert and factor out getStatusCode and getHeaders to utils.dart. Created 7 years, 6 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 | « pkg/http_server/test/utils.dart ('k') | pkg/http_server/test/virtual_host_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 import 'dart:async'; 5 import 'dart:async';
6 import 'dart:io'; 6 import 'dart:io';
7 7
8 import "package:unittest/unittest.dart"; 8 import "package:unittest/unittest.dart";
9 import "package:http_server/http_server.dart"; 9 import "package:http_server/http_server.dart";
10 10
11 11 import 'utils.dart';
12 Future<int> getStatusCode(int port,
13 String path,
14 {DateTime ifModifiedSince}) {
15 return new HttpClient().get('localhost', port, path)
16 .then((request) {
17 if (ifModifiedSince != null) {
18 request.headers.ifModifiedSince = ifModifiedSince;
19 }
20 return request.close();
21 })
22 .then((response) => response.drain().then(
23 (_) => response.statusCode));
24 }
25
26 Future<HttpHeaders> getHeaders(int port, String path) {
27 return new HttpClient().get('localhost', port, path)
28 .then((request) => request.close())
29 .then((response) => response.drain().then(
30 (_) => response.headers));
31 }
32 12
33 13
34 void main() { 14 void main() {
35 group('serve-root', () { 15 group('serve-root', () {
36 test('dir-exists', () { 16 test('dir-exists', () {
37 expect(HttpServer.bind('localhost', 0).then((server) { 17 expect(HttpServer.bind('localhost', 0).then((server) {
38 var dir = new Directory('').createTempSync(); 18 var dir = new Directory('').createTempSync();
39 var virDir = new VirtualDirectory(dir.path); 19 var virDir = new VirtualDirectory(dir.path);
40 20
41 virDir.serve(server); 21 virDir.serve(server);
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 .whenComplete(() { 281 .whenComplete(() {
302 server.close(); 282 server.close();
303 dir.deleteSync(recursive: true); 283 dir.deleteSync(recursive: true);
304 }); 284 });
305 }), completion(equals(HttpStatus.OK))); 285 }), completion(equals(HttpStatus.OK)));
306 }); 286 });
307 }); 287 });
308 }); 288 });
309 } 289 }
310 290
OLDNEW
« no previous file with comments | « pkg/http_server/test/utils.dart ('k') | pkg/http_server/test/virtual_host_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698