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) { |