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

Unified Diff: sdk/lib/_internal/pub/test/serve/utils.dart

Issue 137233021: Support index.html in pub serve. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: code review Created 6 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sdk/lib/_internal/pub/test/serve/serves_index_html_for_directories_test.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/_internal/pub/test/serve/utils.dart
diff --git a/sdk/lib/_internal/pub/test/serve/utils.dart b/sdk/lib/_internal/pub/test/serve/utils.dart
index 6ae1e1ffb66644f018f076f1fd827fb0cd52a6b3..ef58d330a2701197292eee3ec0c627edd76585b6 100644
--- a/sdk/lib/_internal/pub/test/serve/utils.dart
+++ b/sdk/lib/_internal/pub/test/serve/utils.dart
@@ -9,6 +9,7 @@ import 'dart:convert';
import 'dart:io';
import 'package:http/http.dart' as http;
+import 'package:path/path.dart' as p;
import 'package:scheduled_test/scheduled_process.dart';
import 'package:scheduled_test/scheduled_test.dart';
@@ -189,6 +190,24 @@ void requestShould404(String urlPath) {
}, "request $urlPath");
}
+/// Schedules an HTTP request to the running pub server with [urlPath] and
+/// verifies that it responds with a redirect to the given [redirectTarget].
+///
+/// [redirectTarget] may be either a [Matcher] or a string to match an exact
+/// URL.
+void requestShouldRedirect(String urlPath, redirectTarget) {
+ schedule(() {
+ var request = new http.Request("GET",
+ Uri.parse("http://127.0.0.1:$_port/$urlPath"));
+ request.followRedirects = false;
+ return request.send().then((response) {
+ expect(response.statusCode ~/ 100, equals(3));
+
+ expect(response.headers, containsPair('location', redirectTarget));
+ });
+ }, "request $urlPath");
+}
+
/// Schedules an HTTP POST to the running pub server with [urlPath] and verifies
/// that it responds with a 405.
void postShould405(String urlPath) {
« no previous file with comments | « sdk/lib/_internal/pub/test/serve/serves_index_html_for_directories_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698