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

Side by Side Diff: pkg/http/test/utils.dart

Issue 134873005: Get rid of SafeHttpServer. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 11 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/test/safe_http_server.dart ('k') | pkg/scheduled_test/lib/scheduled_server.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 library test_utils; 5 library test_utils;
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
11 import 'package:http/src/byte_stream.dart'; 11 import 'package:http/src/byte_stream.dart';
12 import 'package:http/src/utils.dart'; 12 import 'package:http/src/utils.dart';
13 import 'package:unittest/unittest.dart'; 13 import 'package:unittest/unittest.dart';
14 14
15 import 'safe_http_server.dart';
16
17 /// The current server instance. 15 /// The current server instance.
18 HttpServer _server; 16 HttpServer _server;
19 17
20 /// The URL for the current server instance. 18 /// The URL for the current server instance.
21 Uri get serverUrl => Uri.parse('http://localhost:${_server.port}'); 19 Uri get serverUrl => Uri.parse('http://localhost:${_server.port}');
22 20
23 /// A dummy URL for constructing requests that won't be sent. 21 /// A dummy URL for constructing requests that won't be sent.
24 Uri get dummyUrl => Uri.parse('http://dartlang.org/'); 22 Uri get dummyUrl => Uri.parse('http://dartlang.org/');
25 23
26 /// Starts a new HTTP server. 24 /// Starts a new HTTP server.
27 Future startServer() { 25 Future startServer() {
28 return SafeHttpServer.bind("localhost", 0).then((s) { 26 return HttpServer.bind("localhost", 0).then((s) {
29 _server = s; 27 _server = s;
30 s.listen((request) { 28 s.listen((request) {
31 var path = request.uri.path; 29 var path = request.uri.path;
32 var response = request.response; 30 var response = request.response;
33 31
34 if (path == '/error') { 32 if (path == '/error') {
35 response.statusCode = 400; 33 response.statusCode = 400;
36 response.contentLength = 0; 34 response.contentLength = 0;
37 response.close(); 35 response.close();
38 return; 36 return;
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 const isSocketException = const _SocketException(); 198 const isSocketException = const _SocketException();
201 199
202 /// A matcher for functions that throw SocketException. 200 /// A matcher for functions that throw SocketException.
203 const Matcher throwsSocketException = 201 const Matcher throwsSocketException =
204 const Throws(isSocketException); 202 const Throws(isSocketException);
205 203
206 class _SocketException extends TypeMatcher { 204 class _SocketException extends TypeMatcher {
207 const _SocketException() : super("SocketException"); 205 const _SocketException() : super("SocketException");
208 bool matches(item, Map matchState) => item is SocketException; 206 bool matches(item, Map matchState) => item is SocketException;
209 } 207 }
OLDNEW
« no previous file with comments | « pkg/http/test/safe_http_server.dart ('k') | pkg/scheduled_test/lib/scheduled_server.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698