org.apache.camel.component.http
Interface HttpBinding

All Known Implementing Classes:
DefaultHttpBinding

public interface HttpBinding

A pluggable strategy for configuring the http binding so reading request and writing response can be customized using the Java Servlet API.

This is also used by the camel-jetty component in the JettyHttpConsumer class.

Version:

Method Summary
 void doWriteExceptionResponse(Throwable exception, javax.servlet.http.HttpServletResponse response)
          Strategy method that writes the response to the http response stream when an exception occurred
 void doWriteFaultResponse(Message message, javax.servlet.http.HttpServletResponse response, Exchange exchange)
          Strategy method that writes the response to the http response stream for a fault message
 void doWriteResponse(Message message, javax.servlet.http.HttpServletResponse response, Exchange exchange)
          Strategy method that writes the response to the http response stream for an OUT message
 HeaderFilterStrategy getHeaderFilterStrategy()
          Gets the header filter strategy
 boolean isUseReaderForPayload()
          Should reader by used instead of input stream.
 Object parseBody(HttpMessage httpMessage)
          Parses the body from a HttpMessage
 void readRequest(javax.servlet.http.HttpServletRequest request, HttpMessage message)
          Strategy to read the given request and bindings it to the given message.
 void setHeaderFilterStrategy(HeaderFilterStrategy headerFilterStrategy)
          Sets the header filter strategy to use.
 void setUseReaderForPayload(boolean useReaderForPayload)
          Should the ServletRequest.getReader() be exposed as the payload of input messages in the Camel Message.getBody() or not.
 void writeResponse(Exchange exchange, javax.servlet.http.HttpServletResponse response)
          Writes the exchange to the servlet response.
 

Method Detail

readRequest

void readRequest(javax.servlet.http.HttpServletRequest request,
                 HttpMessage message)
Strategy to read the given request and bindings it to the given message.

Parameters:
request - the request
message - the message to populate with data from request

parseBody

Object parseBody(HttpMessage httpMessage)
                 throws IOException
Parses the body from a HttpMessage

Parameters:
httpMessage - the http message
Returns:
the parsed body returned as either a InputStream or a Reader depending on the setUseReaderForPayload(boolean) property.
Throws:
IOException - can be thrown

writeResponse

void writeResponse(Exchange exchange,
                   javax.servlet.http.HttpServletResponse response)
                   throws IOException
Writes the exchange to the servlet response.

Default implementation will delegate to the following methods depending on the status of the exchange

Parameters:
exchange - the exchange
response - the http response
Throws:
IOException - can be thrown from http response

doWriteExceptionResponse

void doWriteExceptionResponse(Throwable exception,
                              javax.servlet.http.HttpServletResponse response)
                              throws IOException
Strategy method that writes the response to the http response stream when an exception occurred

Parameters:
exception - the exception occurred
response - the http response
Throws:
IOException - can be thrown from http response

doWriteFaultResponse

void doWriteFaultResponse(Message message,
                          javax.servlet.http.HttpServletResponse response,
                          Exchange exchange)
                          throws IOException
Strategy method that writes the response to the http response stream for a fault message

Parameters:
message - the fault message
response - the http response
exchange - the exchange to provide context for header filtering
Throws:
IOException - can be thrown from http response

doWriteResponse

void doWriteResponse(Message message,
                     javax.servlet.http.HttpServletResponse response,
                     Exchange exchange)
                     throws IOException
Strategy method that writes the response to the http response stream for an OUT message

Parameters:
message - the OUT message
response - the http response
exchange - the exchange to provide context for header filtering
Throws:
IOException - can be thrown from http response

isUseReaderForPayload

boolean isUseReaderForPayload()
Should reader by used instead of input stream.

Returns:
true if reader should be used
See Also:
for more details

setUseReaderForPayload

void setUseReaderForPayload(boolean useReaderForPayload)
Should the ServletRequest.getReader() be exposed as the payload of input messages in the Camel Message.getBody() or not. If false then the ServletRequest.getInputStream() will be exposed.

Is default false.

Parameters:
useReaderForPayload - whether to use reader or not

getHeaderFilterStrategy

HeaderFilterStrategy getHeaderFilterStrategy()
Gets the header filter strategy

Returns:
the strategy

setHeaderFilterStrategy

void setHeaderFilterStrategy(HeaderFilterStrategy headerFilterStrategy)
Sets the header filter strategy to use.

Will default use HttpHeaderFilterStrategy

Parameters:
headerFilterStrategy - the custom strategy


Apache CAMEL