Send data with 404 response

The primary reason is to work around http://dartbug.com/19024, but this is not a hack or temporary code.

R=ricow@google.com

Review URL: https://codereview.chromium.org//301683002

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@36675 260f80e4-7a28-3924-810f-c04153c831b5
This commit is contained in:
ahe@google.com 2014-05-27 13:30:49 +00:00
parent 7a7a63a513
commit c5a9af1d62
2 changed files with 24 additions and 5 deletions

View file

@ -85,7 +85,6 @@ spawn_uri_nested_vm_test: Skip # Issue 14479: This test is timing out.
spawn_uri_missing_from_isolate_test: RuntimeError # http://dartbug.com/17649
spawn_uri_missing_test: Skip # Times out.
[ $compiler == none && $runtime == dartium ]
isolate_stress_test: Skip # Issue 14463
@ -98,7 +97,3 @@ simple_message_test/none: Fail, OK # Issue 13921 Dom isolates don't support spaw
browser/typed_data_message_test: StaticWarning
mint_maker_test: StaticWarning
serialization_test: StaticWarning
[ $compiler == dart2js && ( $runtime == ff ) ]
spawn_uri_missing_from_isolate_test: Skip # http://dartbug.com/19024
spawn_uri_missing_test: Skip # http://dartbug.com/19024

View file

@ -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(