public class DefaultHttpBinding extends Object implements HttpBinding
Modifier and Type | Field and Description |
---|---|
static String |
DATE_FORMAT
The data format used for storing java.util.Date instances as a String value.
|
static String |
DATE_LOCALE_CONVERSION
Whether Date/Locale should be converted to String types (enabled by default)
|
Constructor and Description |
---|
DefaultHttpBinding() |
DefaultHttpBinding(org.apache.camel.spi.HeaderFilterStrategy headerFilterStrategy)
Deprecated.
|
DefaultHttpBinding(HttpCommonEndpoint endpoint)
Deprecated.
|
Modifier and Type | Method and Description |
---|---|
protected boolean |
checkChunked(org.apache.camel.Message message,
org.apache.camel.Exchange exchange) |
protected boolean |
convertDateAndLocaleLocally(org.apache.camel.Exchange exchange) |
protected String |
convertHeaderValueToString(org.apache.camel.Exchange exchange,
Object headerValue) |
protected int |
copyStream(InputStream is,
OutputStream os,
int bufferSize) |
protected void |
doWriteDirectResponse(org.apache.camel.Message message,
javax.servlet.http.HttpServletResponse response,
org.apache.camel.Exchange exchange) |
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(org.apache.camel.Message message,
javax.servlet.http.HttpServletResponse response,
org.apache.camel.Exchange exchange)
Strategy method that writes the response to the http response stream for a fault message
|
protected void |
doWriteGZIPResponse(org.apache.camel.Message message,
javax.servlet.http.HttpServletResponse response,
org.apache.camel.Exchange exchange) |
void |
doWriteResponse(org.apache.camel.Message message,
javax.servlet.http.HttpServletResponse response,
org.apache.camel.Exchange exchange)
Strategy method that writes the response to the http response stream for an OUT message
|
String |
getFileNameExtWhitelist()
Whitelist of accepted filename extensions for accepting uploaded files.
|
org.apache.camel.spi.HeaderFilterStrategy |
getHeaderFilterStrategy()
Gets the header filter strategy
|
protected static SimpleDateFormat |
getHttpDateFormat() |
boolean |
isAllowJavaSerializedObject()
Whether to allow java serialization when a request uses context-type=application/x-java-serialized-object
This is by default turned off.
|
boolean |
isEagerCheckContentAvailable()
Whether to eager check whether the HTTP requests has content if the content-length header is 0 or not present.
|
boolean |
isMapHttpMessageBody()
Whether to allow Exchange Body HTTP mapping
|
boolean |
isMapHttpMessageFormUrlEncodedBody()
Whether to allow Exchange Form URL Encoded Body HTTP mapping
|
boolean |
isMapHttpMessageHeaders()
Whether to allow Exchange Headers HTTP mapping
|
boolean |
isMuteException()
If enabled and an Exchange failed processing on the consumer side the response's body won't contain the
exception's stack trace.
|
protected boolean |
isText(String contentType) |
boolean |
isTransferException()
If enabled and an Exchange failed processing on the consumer side, and if the caused Exception was send back
serialized in the response as a application/x-java-serialized-object content type (for example using Jetty or
Servlet Camel components).
|
boolean |
isUseReaderForPayload()
Should reader by used instead of input stream.
|
Object |
parseBody(HttpMessage httpMessage)
Parses the body from a
HttpMessage |
protected void |
populateAttachments(javax.servlet.http.HttpServletRequest request,
HttpMessage message) |
protected void |
populateRequestParameters(javax.servlet.http.HttpServletRequest request,
HttpMessage message) |
protected void |
readBody(javax.servlet.http.HttpServletRequest request,
HttpMessage message) |
protected void |
readFormUrlEncodedBody(javax.servlet.http.HttpServletRequest request,
HttpMessage message) |
protected void |
readHeaders(javax.servlet.http.HttpServletRequest request,
HttpMessage message) |
void |
readRequest(javax.servlet.http.HttpServletRequest request,
HttpMessage message)
Strategy to read the given request and bindings it to the given message.
|
void |
setAllowJavaSerializedObject(boolean allowJavaSerializedObject)
Whether to allow java serialization when a request uses context-type=application/x-java-serialized-object
This is by default turned off.
|
void |
setEagerCheckContentAvailable(boolean eagerCheckContentAvailable)
Whether to eager check whether the HTTP requests has content if the content-length header is 0 or not present.
|
void |
setFileNameExtWhitelist(String fileNameExtWhitelist)
Whitelist of accepted filename extensions for accepting uploaded files.
|
void |
setHeaderFilterStrategy(org.apache.camel.spi.HeaderFilterStrategy headerFilterStrategy)
Sets the header filter strategy to use.
|
void |
setMapHttpMessageBody(boolean mapHttpMessageBody)
Whether to allow Exchange Body HTTP mapping
This is by default turned on.
|
void |
setMapHttpMessageFormUrlEncodedBody(boolean mapHttpMessageFormUrlEncodedBody)
Whether to allow Exchange Form URL Encoded Body HTTP mapping
This is by default turned on.
|
void |
setMapHttpMessageHeaders(boolean mapHttpMessageHeaders)
Whether to allow Exchange Headers HTTP mapping
This is by default turned on.
|
void |
setMuteException(boolean muteException)
If enabled and an Exchange failed processing on the consumer side the response's body won't contain the
exception's stack trace.
|
void |
setTransferException(boolean transferException)
If enabled and an Exchange failed processing on the consumer side, and if the caused Exception was send back
serialized in the response as a application/x-java-serialized-object content type (for example using Jetty or
Servlet Camel components).
|
void |
setUseReaderForPayload(boolean useReaderForPayload)
Should the
ServletRequest.getReader() be exposed as the payload of input messages
in the Camel Message.getBody() or not. |
protected static String |
toHttpDate(Date date) |
protected static String |
toHttpLanguage(Locale locale) |
void |
writeResponse(org.apache.camel.Exchange exchange,
javax.servlet.http.HttpServletResponse response)
Writes the exchange to the servlet response.
|
public static final String DATE_LOCALE_CONVERSION
public static final String DATE_FORMAT
public DefaultHttpBinding()
@Deprecated public DefaultHttpBinding(org.apache.camel.spi.HeaderFilterStrategy headerFilterStrategy)
@Deprecated public DefaultHttpBinding(HttpCommonEndpoint endpoint)
public void readRequest(javax.servlet.http.HttpServletRequest request, HttpMessage message)
HttpBinding
readRequest
in interface HttpBinding
request
- the requestmessage
- the message to populate with data from requestprotected void readHeaders(javax.servlet.http.HttpServletRequest request, HttpMessage message)
protected void readBody(javax.servlet.http.HttpServletRequest request, HttpMessage message)
protected void populateRequestParameters(javax.servlet.http.HttpServletRequest request, HttpMessage message)
protected void readFormUrlEncodedBody(javax.servlet.http.HttpServletRequest request, HttpMessage message) throws UnsupportedEncodingException
UnsupportedEncodingException
protected void populateAttachments(javax.servlet.http.HttpServletRequest request, HttpMessage message)
public void writeResponse(org.apache.camel.Exchange exchange, javax.servlet.http.HttpServletResponse response) throws IOException
HttpBinding
writeResponse
in interface HttpBinding
exchange
- the exchangeresponse
- the http responseIOException
- can be thrown from http responsepublic void doWriteExceptionResponse(Throwable exception, javax.servlet.http.HttpServletResponse response) throws IOException
HttpBinding
doWriteExceptionResponse
in interface HttpBinding
exception
- the exception occurredresponse
- the http responseIOException
- can be thrown from http responsepublic void doWriteFaultResponse(org.apache.camel.Message message, javax.servlet.http.HttpServletResponse response, org.apache.camel.Exchange exchange) throws IOException
HttpBinding
doWriteFaultResponse
in interface HttpBinding
message
- the fault messageresponse
- the http responseexchange
- the exchange to provide context for header filteringIOException
- can be thrown from http responsepublic void doWriteResponse(org.apache.camel.Message message, javax.servlet.http.HttpServletResponse response, org.apache.camel.Exchange exchange) throws IOException
HttpBinding
doWriteResponse
in interface HttpBinding
message
- the OUT messageresponse
- the http responseexchange
- the exchange to provide context for header filteringIOException
- can be thrown from http responseprotected String convertHeaderValueToString(org.apache.camel.Exchange exchange, Object headerValue)
protected boolean convertDateAndLocaleLocally(org.apache.camel.Exchange exchange)
protected boolean isText(String contentType)
protected int copyStream(InputStream is, OutputStream os, int bufferSize) throws IOException
IOException
protected void doWriteDirectResponse(org.apache.camel.Message message, javax.servlet.http.HttpServletResponse response, org.apache.camel.Exchange exchange) throws IOException
IOException
protected boolean checkChunked(org.apache.camel.Message message, org.apache.camel.Exchange exchange)
protected void doWriteGZIPResponse(org.apache.camel.Message message, javax.servlet.http.HttpServletResponse response, org.apache.camel.Exchange exchange) throws IOException
IOException
public Object parseBody(HttpMessage httpMessage) throws IOException
HttpBinding
HttpMessage
parseBody
in interface HttpBinding
httpMessage
- the http messageInputStream
or a
Reader
depending on the HttpBinding.setUseReaderForPayload(boolean)
property.IOException
- can be thrownpublic boolean isUseReaderForPayload()
HttpBinding
isUseReaderForPayload
in interface HttpBinding
for more details
public void setUseReaderForPayload(boolean useReaderForPayload)
HttpBinding
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.setUseReaderForPayload
in interface HttpBinding
useReaderForPayload
- whether to use reader or notpublic boolean isEagerCheckContentAvailable()
HttpBinding
isEagerCheckContentAvailable
in interface HttpBinding
public void setEagerCheckContentAvailable(boolean eagerCheckContentAvailable)
HttpBinding
setEagerCheckContentAvailable
in interface HttpBinding
public boolean isTransferException()
HttpBinding
isTransferException
in interface HttpBinding
public void setTransferException(boolean transferException)
HttpBinding
setTransferException
in interface HttpBinding
public boolean isMuteException()
HttpBinding
isMuteException
in interface HttpBinding
public void setMuteException(boolean muteException)
HttpBinding
setMuteException
in interface HttpBinding
public boolean isAllowJavaSerializedObject()
HttpBinding
isAllowJavaSerializedObject
in interface HttpBinding
public void setAllowJavaSerializedObject(boolean allowJavaSerializedObject)
HttpBinding
setAllowJavaSerializedObject
in interface HttpBinding
allowJavaSerializedObject
- true to allow serializing java objectspublic org.apache.camel.spi.HeaderFilterStrategy getHeaderFilterStrategy()
HttpBinding
getHeaderFilterStrategy
in interface HttpBinding
public void setHeaderFilterStrategy(org.apache.camel.spi.HeaderFilterStrategy headerFilterStrategy)
HttpBinding
HttpHeaderFilterStrategy
setHeaderFilterStrategy
in interface HttpBinding
headerFilterStrategy
- the custom strategypublic boolean isMapHttpMessageBody()
HttpBinding
isMapHttpMessageBody
in interface HttpBinding
public void setMapHttpMessageBody(boolean mapHttpMessageBody)
HttpBinding
setMapHttpMessageBody
in interface HttpBinding
public boolean isMapHttpMessageHeaders()
HttpBinding
isMapHttpMessageHeaders
in interface HttpBinding
public void setMapHttpMessageHeaders(boolean mapHttpMessageHeaders)
HttpBinding
setMapHttpMessageHeaders
in interface HttpBinding
public boolean isMapHttpMessageFormUrlEncodedBody()
HttpBinding
isMapHttpMessageFormUrlEncodedBody
in interface HttpBinding
public void setMapHttpMessageFormUrlEncodedBody(boolean mapHttpMessageFormUrlEncodedBody)
HttpBinding
setMapHttpMessageFormUrlEncodedBody
in interface HttpBinding
public String getFileNameExtWhitelist()
HttpBinding
getFileNameExtWhitelist
in interface HttpBinding
public void setFileNameExtWhitelist(String fileNameExtWhitelist)
HttpBinding
setFileNameExtWhitelist
in interface HttpBinding
protected static SimpleDateFormat getHttpDateFormat()
Apache Camel