diff options
author | Nicolas "Pixel" Noble <pixel@nobis-crew.org> | 2012-02-28 04:57:59 +0100 |
---|---|---|
committer | Nicolas "Pixel" Noble <pixel@nobis-crew.org> | 2012-02-28 04:57:59 +0100 |
commit | 30c37eb549c17b29a8131598cc06aeaf374896f5 (patch) | |
tree | 0105edcf5c8643c83a73f205577061686283a18e /tests | |
parent | 3998f46d06ec5235ade776ec8615e081dd909920 (diff) |
Having a slightly better approach for writing Http responses.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test-Http.cc | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/tests/test-Http.cc b/tests/test-Http.cc index e6ba38d..af78e43 100644 --- a/tests/test-Http.cc +++ b/tests/test-Http.cc @@ -13,12 +13,8 @@ class TestAction : public HttpServer::Action { }; bool TestAction::Do(HttpServer * server, Http::Request & req, HttpServer::Action::ActionMatch & match, IO<Handle> out) throw (GeneralException) { - static const char str[] = -"HTTP/1.1 200 Found\r\n" -"Content-Type: text/html; charset=UTF-8\r\n" -"Content-Length: 266\r\n" -"Server: " DAEMON_NAME "\r\n" -"\r\n" + HttpServer::Response response(server, req, out); + response->writeString( "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"\n" "\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n" "<html xmlns=\"http://www.w3.org/1999/xhtml\">\n" @@ -29,9 +25,9 @@ bool TestAction::Do(HttpServer * server, Http::Request & req, HttpServer::Action " <body>\n" " This is a test document.\n" " </body>\n" -"</html>\n"; +"</html>\n"); - out->forceWrite(str, sizeof(str) - 1); + response.Flush(); return true; } |