public boolean processRequest(
final SimpleHttpServerConnection conn,
final SimpleRequest request) throws IOException
{
RequestLine requestLine = request.getRequestLine();
ResponseWriter out = conn.getWriter();
if ("GET".equals(requestLine.getMethod())
&& "/".equals(requestLine.getUri())) {
requestNo++;
out.println("HTTP/1.1 200 OK");
out.println("Content-Type: text/html");
out.println("Content-Length: 5");
out.println("Connection: keep-alive");
out.println();
out.println("12345"); // send exactly 5 bytes
// and some more garbage!
out.println("AND SOME MORE\r\nGARBAGE!");
out.println("HTTP/1.0 404 Not Found");
out.println("Content-Type: text/plain");
out.println("");
out.println("THIS-IS-A-FAKE-RESPONSE!");
out.flush();
// process max. 2 subsequents requests per connection
if (requestNo < 2) {
conn.setKeepAlive(true);
}
}