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

Unified Diff: dart/tools/testing/dart/http_server.dart

Issue 301683002: Send data with 404 response (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Merged with r36673 Created 6 years, 7 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 | « dart/tests/isolate/isolate.status ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dart/tools/testing/dart/http_server.dart
diff --git a/dart/tools/testing/dart/http_server.dart b/dart/tools/testing/dart/http_server.dart
index 42fed87bc8e34b8a1f233990e9eb153b4029fd6a..f686e24eb2cf078f49f8d5b136b3d34c71e3bad2 100644
--- a/dart/tools/testing/dart/http_server.dart
+++ b/dart/tools/testing/dart/http_server.dart
@@ -6,6 +6,10 @@ library http_server;
import 'dart:async';
import 'dart:io';
+
+import 'dart:convert' show
+ HtmlEscape;
+
import 'test_suite.dart'; // For TestUtils.
// TODO(efortuna): Rewrite to not use the args library and simply take an
// expected number of arguments, so test.dart doesn't rely on the args library?
@@ -379,6 +383,26 @@ class TestingServers {
'"${request.uri.path}"');
}
response.statusCode = HttpStatus.NOT_FOUND;
+
+ // Send a nice HTML page detailing the error message. Most browsers expect
+ // this, for example, Chrome will simply display a blank page if you don't
+ // provide any information. A nice side effect of this is to work around
+ // Firefox bug 1016313
+ // (https://bugzilla.mozilla.org/show_bug.cgi?id=1016313).
+ response.headers.set(HttpHeaders.CONTENT_TYPE, 'text/html');
+ String escapedPath = const HtmlEscape().convert(request.uri.path);
+ response.write("""
+<!DOCTYPE html>
+<html lang='en'>
+<head>
+<title>Not Found</title>
+</head>
+<body>
+<h1>Not Found</h1>
+<p style='white-space:pre'>The file '$escapedPath\' could not be found.</p>
+</body>
+</html>
+""");
response.close();
response.done.catchError((e) {
DebugLogger.warning(
« no previous file with comments | « dart/tests/isolate/isolate.status ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698