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

Unified Diff: pkg/http/test/utils.dart

Issue 11394003: Add an HTTP client based on Curl. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 1 month 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
« pkg/http/test/curl_client_test.dart ('K') | « pkg/http/test/curl_client_test.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/http/test/utils.dart
diff --git a/pkg/http/test/utils.dart b/pkg/http/test/utils.dart
index 9b4d7e9ca8ad863582c84c539c1bc130cfcbfb48..19a3cf32c113bf838dba9352f69d478a1d221fe8 100644
--- a/pkg/http/test/utils.dart
+++ b/pkg/http/test/utils.dart
@@ -28,6 +28,24 @@ void startServer() {
_server.addRequestHandler((request) => request.path == '/error',
(request, response) {
response.statusCode = 400;
+ response.contentLength = 0;
+ response.outputStream.close();
+ });
+
+ _server.addRequestHandler((request) => request.path == '/loop',
+ (request, response) {
+ var n = int.parse(new Uri.fromString(request.uri).query);
+ response.statusCode = 302;
+ response.headers.set('location', '/loop?${n + 1}');
+ response.contentLength = 0;
+ response.outputStream.close();
+ });
+
+ _server.addRequestHandler((request) => request.path == '/redirect',
+ (request, response) {
+ response.statusCode = 302;
+ response.headers.set('location', '/');
+ response.contentLength = 0;
response.outputStream.close();
});
@@ -95,7 +113,6 @@ class _Parse extends BaseMatcher {
_Parse(this._matcher);
bool matches(item, MatchState matchState) {
- print("_Parse.matches [$item]");
if (item is! String) return false;
var parsed;
@@ -138,3 +155,19 @@ class _HttpException extends TypeMatcher {
const _HttpException() : super("HttpException");
bool matches(item, MatchState matchState) => item is HttpException;
}
+
+/// A matcher for RedirectLimitExceededExceptions.
+const isRedirectLimitExceededException =
+ const _RedirectLimitExceededException();
+
+/// A matcher for functions that throw RedirectLimitExceededException.
+const Matcher throwsRedirectLimitExceededException =
+ const Throws(isRedirectLimitExceededException);
+
+class _RedirectLimitExceededException extends TypeMatcher {
+ const _RedirectLimitExceededException() :
+ super("RedirectLimitExceededException");
+
+ bool matches(item, MatchState matchState) =>
+ item is RedirectLimitExceededException;
+}
« pkg/http/test/curl_client_test.dart ('K') | « pkg/http/test/curl_client_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698