pygmy.core
Interface ResponseListener


public interface ResponseListener

Interface for monitoring progress of sending HttpResponse. Class that implement this interface can listen for all HttpResponses being sent to clients. They also can veto or block certain responses during their transmissions by throwing a java.lang.IOException in the notify method. The setResponseListener method must be called in order to set the ResponseListener for a Server.


Method Summary
 void endTransfer(HttpRequest request, java.lang.Exception e)
          This method is called once the transmission of the HttpResponse has concluded.
 void notify(HttpRequest request, int bytesSent, int totalLength)
          This method is called at regular intervals to notify the progress of a HttpResponse transmission.
 void startTransfer(HttpRequest request)
          This method is called at the beginning of an HttpRequest.
 

Method Detail

startTransfer

void startTransfer(HttpRequest request)
This method is called at the beginning of an HttpRequest.

Parameters:
request - the request that is being respond to.

notify

void notify(HttpRequest request,
            int bytesSent,
            int totalLength)
            throws java.io.IOException
This method is called at regular intervals to notify the progress of a HttpResponse transmission. The number of time this method is called depends on how much data is being set to the client. It will be called at least once.

Parameters:
request - the request that is being responded to.
bytesSent - the amount of data sent so far in bytes. Always be zero or greater.
totalLength - the total length of the data being sent in bytes. Can be -1 for an unknown total.
Throws:
java.io.IOException - throws an IOException if a ResponseListener wishes to interrupt the transmission.

endTransfer

void endTransfer(HttpRequest request,
                 java.lang.Exception e)
This method is called once the transmission of the HttpResponse has concluded.

Parameters:
request - the request that is being respond to.
e - the exception if there was one that ended the transmission. It is null if it completed successfully.