public class DefaultMIMEHandler extends java.lang.Object implements HTTPRequestHandler, HTTPResponseHandler
This implementation allows the registration of MIME part handlers ( MIMEHandler )
which handle the incoming content within the MIME part.
The registration of such a MIME part handler can be done for one MIME part, a sequence of MIME parts or all MIME parts with, or without a content type.
register(MIMEHandler)
register(int, MIMEHandler)
register(ContentType, MIMEHandler)
register(int, int, MIMEHandler)
register(ContentType, int, MIMEHandler)
register(ContentType, int, int, MIMEHandler)
If a MIME part handler matches the part (and the content type if given by registration) a new
thread ( DefaultMIMEHandler.StreamConsumerThread ) will be started and the thread will
handle the MIME exchange.
The thread in which the DefaultMIMEHandler acts will wait until the DefaultMIMEHandler.StreamConsumerThread has read the whole MIME part or ends correctly.
If the DefaultMIMEHandler.StreamConsumerThread ends without reading the complete MIME
part, the omitted bytes will be consumed to wake up the DefaultMIMEHandler.
If the DefaultMIMEHandler is woken up, it will check for another MIME part. If another
MIME part exists, the handling procedure will start again.
If no other MIME part exists, the HTTP response is generated by the DefaultMIMEHandler.
Every MIMEHandler which handles a MIME part can add a MIMEEntityOutput into
the MIME exchange for the response. If all MIME parts have been read, the generating process will
begin.
To generate the HTTP response the DefaultMIMEHandler looks at the queued MIME entities.
| Constructor and Description |
|---|
DefaultMIMEHandler()
Creates a default MIME handler.
|
| Modifier and Type | Method and Description |
|---|---|
static java.lang.String |
createMimeBoundary() |
HTTPResponse |
handle(HTTPRequestHeader header,
HTTPInputStream body,
ConnectionInfo connectionInfo,
MonitoringContext context)
Handles a HTTP request.
|
void |
handle(HTTPResponseHeader header,
HTTPInputStream body,
HTTPRequest request,
ConnectionInfo connectionInfo,
MonitoringContext context)
Handles incoming HTTP response.
|
void |
register(ContentType type,
int partMin,
int partMax,
MIMEHandler handler)
Allows the registration of a MIME part handler with content type for the MIME parts from a
given start until a given end.
|
void |
register(ContentType type,
int partMax,
MIMEHandler handler)
Allows the registration of a MIME part handler with content type for the MIME parts from a
given start until a given end.
|
void |
register(ContentType type,
MIMEHandler handler)
Allows the registration of a MIME part handler with content type for every MIME part.
|
void |
register(int partMin,
int partMax,
MIMEHandler handler)
Allows the registration of a MIME part handler without content type for the MIME parts from
given start until the given end.
|
void |
register(int partMax,
MIMEHandler handler)
Allows the registration of a MIME part handler without content type from the first MIME part
until the given part.
|
void |
register(MIMEHandler handler)
Allows the registration of a MIME part handler without content type for every MIME part.
|
public static java.lang.String createMimeBoundary()
public void register(MIMEHandler handler)
handler - the handler which handles the request.public void register(ContentType type, MIMEHandler handler)
handler - the handler which handles the request.public void register(int partMax,
MIMEHandler handler)
handler - the handler which handles the request.public void register(int partMin,
int partMax,
MIMEHandler handler)
handler - the handler which handles the request.public void register(ContentType type, int partMax, MIMEHandler handler)
handler - the handler which handles the request.public void register(ContentType type, int partMin, int partMax, MIMEHandler handler)
handler - the handler which handles the request.public HTTPResponse handle(HTTPRequestHeader header, HTTPInputStream body, ConnectionInfo connectionInfo, MonitoringContext context) throws java.io.IOException
HTTPRequestHandlerhandle in interface HTTPRequestHandlerheader - the http request headerbody - the http request bodyconnectionInfo - transport/addressing related information attached to the requestjava.io.IOExceptionpublic void handle(HTTPResponseHeader header, HTTPInputStream body, HTTPRequest request, ConnectionInfo connectionInfo, MonitoringContext context) throws java.io.IOException
HTTPResponseHandlerhandle in interface HTTPResponseHandlerheader - the HTTP response header.body - the HTTP response body.connectionInfo - transport/addressing information attached to the responsejava.io.IOException