Package org.apache.camel.http.common
Class DefaultHttpBinding
java.lang.Object
org.apache.camel.http.common.DefaultHttpBinding
- All Implemented Interfaces:
HttpBinding
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionDefaultHttpBinding(HttpCommonEndpoint endpoint) Deprecated.DefaultHttpBinding(org.apache.camel.spi.HeaderFilterStrategy headerFilterStrategy) Deprecated. -
Method Summary
Modifier and TypeMethodDescriptionprotected booleancheckChunked(org.apache.camel.Message message, org.apache.camel.Exchange exchange) protected booleanconvertDateAndLocaleLocally(org.apache.camel.Exchange exchange) protected StringconvertHeaderValueToString(org.apache.camel.Exchange exchange, Object headerValue) protected intcopyStream(InputStream is, OutputStream os, int bufferSize) protected voiddoWriteDirectResponse(org.apache.camel.Message message, jakarta.servlet.http.HttpServletResponse response, org.apache.camel.Exchange exchange) voiddoWriteExceptionResponse(Throwable exception, jakarta.servlet.http.HttpServletResponse response) Strategy method that writes the response to the http response stream when an exception occurredvoiddoWriteFaultResponse(org.apache.camel.Message message, jakarta.servlet.http.HttpServletResponse response, org.apache.camel.Exchange exchange) Strategy method that writes the response to the http response stream for a fault messageprotected voiddoWriteGZIPResponse(org.apache.camel.Message message, jakarta.servlet.http.HttpServletResponse response, org.apache.camel.Exchange exchange) voiddoWriteResponse(org.apache.camel.Message message, jakarta.servlet.http.HttpServletResponse response, org.apache.camel.Exchange exchange) Strategy method that writes the response to the http response stream for an OUT messageWhitelist of accepted filename extensions for accepting uploaded files.org.apache.camel.spi.HeaderFilterStrategyGets the header filter strategyprotected static SimpleDateFormatprotected StringgetRawPath(jakarta.servlet.http.HttpServletRequest request) booleanWhether to allow java serialization when a request uses context-type=application/x-java-serialized-objectbooleanWhether to eager check whether the HTTP requests has content if the content-length header is 0 or not present.booleanIf enabled and an Exchange failed processing on the consumer side the exception's stack trace will be logged when the exception stack trace is not sent in the response's body.booleanWhether to allow Exchange Body HTTP mappingbooleanWhether to allow Exchange Form URL Encoded Body HTTP mappingbooleanWhether to allow Exchange Headers HTTP mappingbooleanIf enabled and an Exchange failed processing on the consumer side the response's body won't contain the exception's stack trace.protected booleanbooleanIf 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).booleanShould reader by used instead of input stream.parseBody(jakarta.servlet.http.HttpServletRequest request, org.apache.camel.Message message) Parses the body from servlet requestprotected voidpopulateAttachments(jakarta.servlet.http.HttpServletRequest request, org.apache.camel.Message message) protected voidpopulateRequestParameters(jakarta.servlet.http.HttpServletRequest request, org.apache.camel.Message message) protected voidreadBody(jakarta.servlet.http.HttpServletRequest request, org.apache.camel.Message message) protected voidreadFormUrlEncodedBody(jakarta.servlet.http.HttpServletRequest request, org.apache.camel.Message message) protected voidreadHeaders(jakarta.servlet.http.HttpServletRequest request, org.apache.camel.Message message) voidreadRequest(jakarta.servlet.http.HttpServletRequest request, org.apache.camel.Message message) Strategy to read the given request and bindings it to the given message.voidsetAllowJavaSerializedObject(boolean allowJavaSerializedObject) Whether to allow java serialization when a request uses context-type=application/x-java-serialized-objectvoidsetEagerCheckContentAvailable(boolean eagerCheckContentAvailable) Whether to eager check whether the HTTP requests has content if the content-length header is 0 or not present.voidsetFileNameExtWhitelist(String fileNameExtWhitelist) Whitelist of accepted filename extensions for accepting uploaded files.voidsetHeaderFilterStrategy(org.apache.camel.spi.HeaderFilterStrategy headerFilterStrategy) Sets the header filter strategy to use.voidsetLogException(boolean logException) If enabled and an Exchange failed processing on the consumer side the exception's stack trace will be logged when the exception stack trace is not sent in the response's body.voidsetMapHttpMessageBody(boolean mapHttpMessageBody) Whether to allow Exchange Body HTTP mappingvoidsetMapHttpMessageFormUrlEncodedBody(boolean mapHttpMessageFormUrlEncodedBody) Whether to allow Exchange Form URL Encoded Body HTTP mappingvoidsetMapHttpMessageHeaders(boolean mapHttpMessageHeaders) Whether to allow Exchange Headers HTTP mappingvoidsetMuteException(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.voidsetTransferException(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).voidsetUseReaderForPayload(boolean useReaderForPayload) Should theServletRequest.getReader()be exposed as the payload of input messages in the CamelMessage.getBody()or not.protected static StringtoHttpDate(Date date) protected static StringtoHttpLanguage(Locale locale) voidwriteResponse(org.apache.camel.Exchange exchange, jakarta.servlet.http.HttpServletResponse response) Writes the exchange to the servlet response.
-
Field Details
-
DATE_LOCALE_CONVERSION
Whether Date/Locale should be converted to String types (enabled by default)- See Also:
-
DATE_FORMAT
The data format used for storing java.util.Date instances as a String value.- See Also:
-
-
Constructor Details
-
DefaultHttpBinding
public DefaultHttpBinding() -
DefaultHttpBinding
@Deprecated public DefaultHttpBinding(org.apache.camel.spi.HeaderFilterStrategy headerFilterStrategy) Deprecated. -
DefaultHttpBinding
Deprecated.
-
-
Method Details
-
readRequest
public void readRequest(jakarta.servlet.http.HttpServletRequest request, org.apache.camel.Message message) Description copied from interface:HttpBindingStrategy to read the given request and bindings it to the given message.- Specified by:
readRequestin interfaceHttpBinding- Parameters:
request- the requestmessage- the message to populate with data from request
-
readHeaders
protected void readHeaders(jakarta.servlet.http.HttpServletRequest request, org.apache.camel.Message message) -
readBody
protected void readBody(jakarta.servlet.http.HttpServletRequest request, org.apache.camel.Message message) -
populateRequestParameters
protected void populateRequestParameters(jakarta.servlet.http.HttpServletRequest request, org.apache.camel.Message message) -
readFormUrlEncodedBody
protected void readFormUrlEncodedBody(jakarta.servlet.http.HttpServletRequest request, org.apache.camel.Message message) throws UnsupportedEncodingException - Throws:
UnsupportedEncodingException
-
getRawPath
-
populateAttachments
protected void populateAttachments(jakarta.servlet.http.HttpServletRequest request, org.apache.camel.Message message) -
writeResponse
public void writeResponse(org.apache.camel.Exchange exchange, jakarta.servlet.http.HttpServletResponse response) throws IOException Description copied from interface:HttpBindingWrites the exchange to the servlet response. Default implementation will delegate to the following methods depending on the status of the exchange- doWriteResponse - processing returns a OUT message
- doWriteFaultResponse - processing returns a fault message
- doWriteResponse - processing returns an exception and status code 500
- Specified by:
writeResponsein interfaceHttpBinding- Parameters:
exchange- the exchangeresponse- the http response- Throws:
IOException- can be thrown from http response
-
doWriteExceptionResponse
public void doWriteExceptionResponse(Throwable exception, jakarta.servlet.http.HttpServletResponse response) throws IOException Description copied from interface:HttpBindingStrategy method that writes the response to the http response stream when an exception occurred- Specified by:
doWriteExceptionResponsein interfaceHttpBinding- Parameters:
exception- the exception occurredresponse- the http response- Throws:
IOException- can be thrown from http response
-
doWriteFaultResponse
public void doWriteFaultResponse(org.apache.camel.Message message, jakarta.servlet.http.HttpServletResponse response, org.apache.camel.Exchange exchange) throws IOException Description copied from interface:HttpBindingStrategy method that writes the response to the http response stream for a fault message- Specified by:
doWriteFaultResponsein interfaceHttpBinding- Parameters:
message- the fault messageresponse- the http responseexchange- the exchange to provide context for header filtering- Throws:
IOException- can be thrown from http response
-
doWriteResponse
public void doWriteResponse(org.apache.camel.Message message, jakarta.servlet.http.HttpServletResponse response, org.apache.camel.Exchange exchange) throws IOException Description copied from interface:HttpBindingStrategy method that writes the response to the http response stream for an OUT message- Specified by:
doWriteResponsein interfaceHttpBinding- Parameters:
message- the OUT messageresponse- the http responseexchange- the exchange to provide context for header filtering- Throws:
IOException- can be thrown from http response
-
convertHeaderValueToString
-
convertDateAndLocaleLocally
protected boolean convertDateAndLocaleLocally(org.apache.camel.Exchange exchange) -
isText
-
copyStream
- Throws:
IOException
-
doWriteDirectResponse
protected void doWriteDirectResponse(org.apache.camel.Message message, jakarta.servlet.http.HttpServletResponse response, org.apache.camel.Exchange exchange) throws IOException - Throws:
IOException
-
checkChunked
protected boolean checkChunked(org.apache.camel.Message message, org.apache.camel.Exchange exchange) -
doWriteGZIPResponse
protected void doWriteGZIPResponse(org.apache.camel.Message message, jakarta.servlet.http.HttpServletResponse response, org.apache.camel.Exchange exchange) throws IOException - Throws:
IOException
-
parseBody
public Object parseBody(jakarta.servlet.http.HttpServletRequest request, org.apache.camel.Message message) throws IOException Description copied from interface:HttpBindingParses the body from servlet request- Specified by:
parseBodyin interfaceHttpBinding- Parameters:
request- the requestmessage- the message- Returns:
- the parsed body returned as either a
InputStreamor aReaderdepending on theHttpBinding.setUseReaderForPayload(boolean)property. - Throws:
IOException- can be thrown
-
isUseReaderForPayload
public boolean isUseReaderForPayload()Description copied from interface:HttpBindingShould reader by used instead of input stream.- Specified by:
isUseReaderForPayloadin interfaceHttpBinding- Returns:
- true if reader should be used
- See Also:
-
setUseReaderForPayload
public void setUseReaderForPayload(boolean useReaderForPayload) Description copied from interface:HttpBindingShould theServletRequest.getReader()be exposed as the payload of input messages in the CamelMessage.getBody()or not. If false then theServletRequest.getInputStream()will be exposed. Is default false.- Specified by:
setUseReaderForPayloadin interfaceHttpBinding- Parameters:
useReaderForPayload- whether to use reader or not
-
isEagerCheckContentAvailable
public boolean isEagerCheckContentAvailable()Description copied from interface:HttpBindingWhether to eager check whether the HTTP requests has content if the content-length header is 0 or not present. This can be turned on in case HTTP clients do not send streamed data.- Specified by:
isEagerCheckContentAvailablein interfaceHttpBinding
-
setEagerCheckContentAvailable
public void setEagerCheckContentAvailable(boolean eagerCheckContentAvailable) Description copied from interface:HttpBindingWhether to eager check whether the HTTP requests has content if the content-length header is 0 or not present. This can be turned on in case HTTP clients do not send streamed data.- Specified by:
setEagerCheckContentAvailablein interfaceHttpBinding
-
isTransferException
public boolean isTransferException()Description copied from interface:HttpBindingIf 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). On the producer side the exception will be deserialized and thrown as is, instead of the HttpOperationFailedException. The caused exception is required to be serialized. This is by default turned off. If you enable this then be aware that Java will deserialize the incoming data from the request to Java and that can be a potential security risk.- Specified by:
isTransferExceptionin interfaceHttpBinding
-
setTransferException
public void setTransferException(boolean transferException) Description copied from interface:HttpBindingIf 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). On the producer side the exception will be deserialized and thrown as is, instead of the HttpOperationFailedException. The caused exception is required to be serialized. This is by default turned off. If you enable this then be aware that Java will deserialize the incoming data from the request to Java and that can be a potential security risk.- Specified by:
setTransferExceptionin interfaceHttpBinding
-
isMuteException
public boolean isMuteException()Description copied from interface:HttpBindingIf enabled and an Exchange failed processing on the consumer side the response's body won't contain the exception's stack trace.- Specified by:
isMuteExceptionin interfaceHttpBinding
-
setMuteException
public void setMuteException(boolean muteException) Description copied from interface:HttpBindingIf enabled and an Exchange failed processing on the consumer side the response's body won't contain the exception's stack trace.- Specified by:
setMuteExceptionin interfaceHttpBinding
-
isLogException
public boolean isLogException()Description copied from interface:HttpBindingIf enabled and an Exchange failed processing on the consumer side the exception's stack trace will be logged when the exception stack trace is not sent in the response's body.- Specified by:
isLogExceptionin interfaceHttpBinding
-
setLogException
public void setLogException(boolean logException) Description copied from interface:HttpBindingIf enabled and an Exchange failed processing on the consumer side the exception's stack trace will be logged when the exception stack trace is not sent in the response's body.- Specified by:
setLogExceptionin interfaceHttpBinding
-
isAllowJavaSerializedObject
public boolean isAllowJavaSerializedObject()Description copied from interface:HttpBindingWhether to allow java serialization when a request uses context-type=application/x-java-serialized-object This is by default turned off. If you enable this then be aware that Java will deserialize the incoming data from the request to Java and that can be a potential security risk.- Specified by:
isAllowJavaSerializedObjectin interfaceHttpBinding
-
setAllowJavaSerializedObject
public void setAllowJavaSerializedObject(boolean allowJavaSerializedObject) Description copied from interface:HttpBindingWhether to allow java serialization when a request uses context-type=application/x-java-serialized-object This is by default turned off. If you enable this then be aware that Java will deserialize the incoming data from the request to Java and that can be a potential security risk.- Specified by:
setAllowJavaSerializedObjectin interfaceHttpBinding- Parameters:
allowJavaSerializedObject- true to allow serializing java objects
-
getHeaderFilterStrategy
public org.apache.camel.spi.HeaderFilterStrategy getHeaderFilterStrategy()Description copied from interface:HttpBindingGets the header filter strategy- Specified by:
getHeaderFilterStrategyin interfaceHttpBinding- Returns:
- the strategy
-
setHeaderFilterStrategy
public void setHeaderFilterStrategy(org.apache.camel.spi.HeaderFilterStrategy headerFilterStrategy) Description copied from interface:HttpBindingSets the header filter strategy to use. Will default useHttpHeaderFilterStrategy- Specified by:
setHeaderFilterStrategyin interfaceHttpBinding- Parameters:
headerFilterStrategy- the custom strategy
-
isMapHttpMessageBody
public boolean isMapHttpMessageBody()Description copied from interface:HttpBindingWhether to allow Exchange Body HTTP mapping- Specified by:
isMapHttpMessageBodyin interfaceHttpBinding
-
setMapHttpMessageBody
public void setMapHttpMessageBody(boolean mapHttpMessageBody) Description copied from interface:HttpBindingWhether to allow Exchange Body HTTP mapping This is by default turned on. If you disable this then be aware that the Exchange body won't be mapped to HTTP- Specified by:
setMapHttpMessageBodyin interfaceHttpBinding
-
isMapHttpMessageHeaders
public boolean isMapHttpMessageHeaders()Description copied from interface:HttpBindingWhether to allow Exchange Headers HTTP mapping- Specified by:
isMapHttpMessageHeadersin interfaceHttpBinding
-
setMapHttpMessageHeaders
public void setMapHttpMessageHeaders(boolean mapHttpMessageHeaders) Description copied from interface:HttpBindingWhether to allow Exchange Headers HTTP mapping This is by default turned on. If you disable this then be aware that the Exchange headers won't be mapped to HTTP- Specified by:
setMapHttpMessageHeadersin interfaceHttpBinding
-
isMapHttpMessageFormUrlEncodedBody
public boolean isMapHttpMessageFormUrlEncodedBody()Description copied from interface:HttpBindingWhether to allow Exchange Form URL Encoded Body HTTP mapping- Specified by:
isMapHttpMessageFormUrlEncodedBodyin interfaceHttpBinding
-
setMapHttpMessageFormUrlEncodedBody
public void setMapHttpMessageFormUrlEncodedBody(boolean mapHttpMessageFormUrlEncodedBody) Description copied from interface:HttpBindingWhether to allow Exchange Form URL Encoded Body HTTP mapping This is by default turned on. If you disable this then be aware that the Exchange Form URL Encoded Body won't be mapped to HTTP- Specified by:
setMapHttpMessageFormUrlEncodedBodyin interfaceHttpBinding
-
getFileNameExtWhitelist
Description copied from interface:HttpBindingWhitelist of accepted filename extensions for accepting uploaded files. Multiple extensions can be separated by comma, such as txt,xml.- Specified by:
getFileNameExtWhitelistin interfaceHttpBinding
-
setFileNameExtWhitelist
Description copied from interface:HttpBindingWhitelist of accepted filename extensions for accepting uploaded files. Multiple extensions can be separated by comma, such as txt,xml.- Specified by:
setFileNameExtWhitelistin interfaceHttpBinding
-
getHttpDateFormat
-
toHttpDate
-
toHttpLanguage
-