net.noderunner.http
Class BasicHttpServer

java.lang.Object
  extended by net.noderunner.http.BasicHttpServer
All Implemented Interfaces:
HttpServer

public class BasicHttpServer
extends Object
implements HttpServer

A very basic HTTP server implementation.

See Also:
BasicHttpClient

Constructor Summary
BasicHttpServer(OutputStream os, InputStream is)
          Constructs a BasicHttpServer that communicates over an input and output stream.
BasicHttpServer(Socket socket)
          Constructs a BasicHttpServer that communicates over a socket.
 
Method Summary
 void close()
          Closes the underlying input and output streams.
 OutputStream getOutputStream()
          Returns a stream for writing data to, if data is to be sent to the client.
 ServerRequest readRequest()
          Reads the HTTP Request information.
 String toString()
          Returns debug information.
 void writeResponse(ServerResponse response)
          Sends response data to the HTTP client.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BasicHttpServer

public BasicHttpServer(Socket socket)
                throws IOException
Constructs a BasicHttpServer that communicates over a socket. The input stream is wrapped in a buffered input stream.

Throws:
IOException

BasicHttpServer

public BasicHttpServer(OutputStream os,
                       InputStream is)
Constructs a BasicHttpServer that communicates over an input and output stream.

Method Detail

readRequest

public ServerRequest readRequest()
                          throws IOException
Description copied from interface: HttpServer
Reads the HTTP Request information.

Specified by:
readRequest in interface HttpServer
Throws:
IOException

writeResponse

public void writeResponse(ServerResponse response)
                   throws IOException
Description copied from interface: HttpServer
Sends response data to the HTTP client.

Specified by:
writeResponse in interface HttpServer
Throws:
HttpException - if the server returned an invalid HTTP response
IOException

getOutputStream

public OutputStream getOutputStream()
Description copied from interface: HttpServer
Returns a stream for writing data to, if data is to be sent to the client.

Specified by:
getOutputStream in interface HttpServer

close

public void close()
           throws IOException
Closes the underlying input and output streams.

Specified by:
close in interface HttpServer
Throws:
IOException

toString

public String toString()
Returns debug information.

Overrides:
toString in class Object


Copyright © 2011. All Rights Reserved.