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

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

Issue 18333003: Correctly url-decode the path segment in the http_server. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Don't allow invalid characters in segment. Created 7 years, 5 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) 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 utils; 5 library utils;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:io'; 8 import 'dart:io';
9 9
10 10
11 Future<int> getStatusCode(int port, 11 Future<int> getStatusCode(int port,
12 String path, 12 String path,
13 {String host, 13 {String host,
14 bool secure: false, 14 bool secure: false,
15 DateTime ifModifiedSince}) { 15 DateTime ifModifiedSince,
16 var uri = (secure ? 16 bool rawPath: false}) {
17 new Uri.https('localhost:$port', path) : 17 var uri;
18 new Uri.http('localhost:$port', path)); 18 if (rawPath) {
19 uri = new Uri(scheme: secure ? 'https' : 'http',
20 host: 'localhost',
21 port: port,
22 path: path);
23 } else {
24 uri = (secure ?
25 new Uri.https('localhost:$port', path) :
26 new Uri.http('localhost:$port', path));
27 }
19 return new HttpClient().getUrl(uri) 28 return new HttpClient().getUrl(uri)
20 .then((request) { 29 .then((request) {
21 if (host != null) request.headers.host = host; 30 if (host != null) request.headers.host = host;
22 if (ifModifiedSince != null) { 31 if (ifModifiedSince != null) {
23 request.headers.ifModifiedSince = ifModifiedSince; 32 request.headers.ifModifiedSince = ifModifiedSince;
24 } 33 }
25 return request.close(); 34 return request.close();
26 }) 35 })
27 .then((response) => response.drain().then( 36 .then((response) => response.drain().then(
28 (_) => response.statusCode)); 37 (_) => response.statusCode));
(...skipping 17 matching lines...) Expand all
46 55
47 const CERTIFICATE = "localhost_cert"; 56 const CERTIFICATE = "localhost_cert";
48 57
49 58
50 setupSecure() { 59 setupSecure() {
51 Path scriptDir = new Path(new Options().script).directoryPath; 60 Path scriptDir = new Path(new Options().script).directoryPath;
52 Path certificateDatabase = scriptDir.append('pkcert'); 61 Path certificateDatabase = scriptDir.append('pkcert');
53 SecureSocket.initialize(database: certificateDatabase.toNativePath(), 62 SecureSocket.initialize(database: certificateDatabase.toNativePath(),
54 password: 'dartdart'); 63 password: 'dartdart');
55 } 64 }
OLDNEW
« no previous file with comments | « pkg/http_server/lib/src/virtual_directory.dart ('k') | pkg/http_server/test/virtual_directory_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698