net.noderunner.http
Class BasicHttpServer

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

public class BasicHttpServer
extends java.lang.Object
implements HttpServer

A very basic HTTP server implementation.

See Also:
BasicHttpClient

Constructor Summary
BasicHttpServer(java.io.OutputStream os, java.io.InputStream is)
          Constructs a BasicHttpServer that communicates over an input and output stream.
BasicHttpServer(java.net.Socket socket)
          Constructs a BasicHttpServer that communicates over a socket.
 
Method Summary
 void close()
          Closes the underlying input and output streams.
 java.io.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.
 java.lang.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(java.net.Socket socket)
                throws java.io.IOException
Constructs a BasicHttpServer that communicates over a socket. The input stream is wrapped in a buffered input stream.

Throws:
java.io.IOException

BasicHttpServer

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

Method Detail

readRequest

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

Specified by:
readRequest in interface HttpServer
Throws:
java.io.IOException

writeResponse

public void writeResponse(ServerResponse response)
                   throws java.io.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
java.io.IOException

getOutputStream

public java.io.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 java.io.IOException
Closes the underlying input and output streams.

Specified by:
close in interface HttpServer
Throws:
java.io.IOException

toString

public java.lang.String toString()
Returns debug information.

Overrides:
toString in class java.lang.Object


Copyright © 2009. All Rights Reserved.