Chromium Code Reviews| 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 039480307b309910d7877d216129c87859b8c2b6..6ac111067158037f6c0248b5acec6ceef8f98d5a 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'; |
| @@ -187,6 +188,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).floor(), equals(3)); |
|
Bob Nystrom
2014/02/11 19:18:17
Why not test for the specific status code?
If you
nweiz
2014/02/11 22:13:41
Because any 30* code is a valid redirect. I didn't
|
| + |
| + 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) { |