irssibot.remote.http
Class ConnectionHandler

java.lang.Object
  |
  +--irssibot.remote.http.ConnectionHandler

class ConnectionHandler
extends java.lang.Object

Connection handler for the HTTP server.

Version:
$Name: $ $Revision: 1.1 $
Author:
Matti Dahlbom

Field Summary
private  byte[] buffer
          Inbound buffer
private static int INBOUND_BUFFER_SIZE
          Inbound buffer size.
 
Constructor Summary
ConnectionHandler()
          Constructs.
 
Method Summary
private  void closeSafely(java.io.InputStream in, java.io.OutputStream out, java.net.Socket socket)
          Closes streams and socket.
private  java.lang.String createResponse(java.lang.String response, java.lang.String message)
          Creates a HTTP response.
 void processRequest(java.net.Socket socket)
          Processes an inbound request.
private  java.lang.String readAll()
          Reads the whole request into the inbound buffer.
private  void sendResponse(java.io.OutputStream out, byte[] data)
          Writes the given bytes to the connection as a HTTP response.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INBOUND_BUFFER_SIZE

private static final int INBOUND_BUFFER_SIZE
Inbound buffer size.

See Also:
Constant Field Values

buffer

private byte[] buffer
Inbound buffer

Constructor Detail

ConnectionHandler

public ConnectionHandler()
Constructs.

Method Detail

closeSafely

private void closeSafely(java.io.InputStream in,
                         java.io.OutputStream out,
                         java.net.Socket socket)
Closes streams and socket.

Parameters:
in - input stream
out - output stream
socket - socket

sendResponse

private void sendResponse(java.io.OutputStream out,
                          byte[] data)
Writes the given bytes to the connection as a HTTP response.

Parameters:
data - HTTP response data

createResponse

private java.lang.String createResponse(java.lang.String response,
                                        java.lang.String message)
Creates a HTTP response.

Parameters:
response - response code, for example "200 OK"
message - message to use as body

readAll

private java.lang.String readAll()
Reads the whole request into the inbound buffer.

Returns:
request as a string

processRequest

public void processRequest(java.net.Socket socket)
Processes an inbound request.

 @param socket socket for the request



IrssiBot (c) 2000-2002 Matti Dahlbom