rabbit.client
Class ClientBase

java.lang.Object
  extended by rabbit.client.ClientBase

public class ClientBase
extends Object

A class for doing http requests.

Author:
Robert Olofsson

Constructor Summary
ClientBase()
          Create a new ClientBase.
 
Method Summary
 Logger getLogger()
          Get the logger that this client is using
 NioHandler getNioHandler()
          Get the NioHandler that this client is using
 URL getRedirectedURL(HttpHeader request, String location)
          Create the url that the response redirected the request to.
 HttpHeader getRequest(String method, String url)
          Submit a new request, using the given method to the given url.
 void sendRequest(HttpHeader request, ClientListener client)
          Send a request and let the client be notified on response.
 void shutdown()
          Shutdown this client handler.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ClientBase

public ClientBase()
           throws IOException
Create a new ClientBase.

Throws:
IOException - if creating the nio handler fails
Method Detail

getRequest

public HttpHeader getRequest(String method,
                             String url)
                      throws IOException
Submit a new request, using the given method to the given url.

Parameters:
method - HEAD or GET or POST or ...
url - the url to do the http request against.
Returns:
the header of the request
Throws:
IOException - if the url is not really an URL

getNioHandler

public NioHandler getNioHandler()
Get the NioHandler that this client is using

Returns:
the current NioHandler

getLogger

public Logger getLogger()
Get the logger that this client is using

Returns:
the current logger

shutdown

public void shutdown()
Shutdown this client handler.


sendRequest

public void sendRequest(HttpHeader request,
                        ClientListener client)
Send a request and let the client be notified on response.

Parameters:
request - the request to send
client - the listener to notify with the response

getRedirectedURL

public URL getRedirectedURL(HttpHeader request,
                            String location)
                     throws IOException
Create the url that the response redirected the request to.

Parameters:
request - the actual request made
location - the redirect location
Returns:
the redirected url
Throws:
IOException - if the redirect url can not be created