Class DefaultNettyHttpBinding
- java.lang.Object
-
- org.apache.camel.component.netty.http.DefaultNettyHttpBinding
-
- All Implemented Interfaces:
Cloneable
,NettyHttpBinding
- Direct Known Subclasses:
RestNettyHttpBinding
public class DefaultNettyHttpBinding extends Object implements NettyHttpBinding, Cloneable
DefaultNettyHttpBinding
.
-
-
Constructor Summary
Constructors Constructor Description DefaultNettyHttpBinding()
DefaultNettyHttpBinding(org.apache.camel.spi.HeaderFilterStrategy headerFilterStrategy)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description DefaultNettyHttpBinding
copy()
protected void
copyCamelHeaders(Map<String,Object> headers, org.apache.camel.Exchange exchange)
Copy camel header from exchange to headers map.org.apache.camel.spi.HeaderFilterStrategy
getHeaderFilterStrategy()
Gets the header filter strategyvoid
populateCamelHeaders(io.netty.handler.codec.http.HttpRequest request, Map<String,Object> headers, org.apache.camel.Exchange exchange, NettyHttpConfiguration configuration)
Binds from NettyHttpRequest
to Camel headers as aMap
.void
populateCamelHeaders(io.netty.handler.codec.http.HttpResponse response, Map<String,Object> headers, org.apache.camel.Exchange exchange, NettyHttpConfiguration configuration)
Binds from NettyHttpResponse
to Camel headers as aMap
.void
setHeaderFilterStrategy(org.apache.camel.spi.HeaderFilterStrategy headerFilterStrategy)
Sets the header filter strategy to use.protected String
shouldUrlDecodeHeader(NettyHttpConfiguration configuration, String headerName, Object value, String charset)
Decodes the header if needed to, or returns the header value as is.org.apache.camel.Message
toCamelMessage(io.netty.handler.codec.http.FullHttpRequest request, org.apache.camel.Exchange exchange, NettyHttpConfiguration configuration)
Binds from NettyHttpRequest
to CamelMessage
.org.apache.camel.Message
toCamelMessage(io.netty.handler.codec.http.FullHttpResponse response, org.apache.camel.Exchange exchange, NettyHttpConfiguration configuration)
Binds from NettyHttpResponse
to CamelMessage
.org.apache.camel.Message
toCamelMessage(InboundStreamHttpRequest request, org.apache.camel.Exchange exchange, NettyHttpConfiguration configuration)
Binds from NettyInboundStreamHttpRequest
to CamelMessage
.org.apache.camel.Message
toCamelMessage(InboundStreamHttpResponse response, org.apache.camel.Exchange exchange, NettyHttpConfiguration configuration)
Binds from NettyInboundStreamHttpResponse
to CamelMessage
.io.netty.handler.codec.http.HttpRequest
toNettyRequest(org.apache.camel.Message message, String fullUri, NettyHttpConfiguration configuration)
Binds from CamelMessage
to NettyHttpRequest
.io.netty.handler.codec.http.HttpResponse
toNettyResponse(org.apache.camel.Message message, NettyHttpConfiguration configuration)
Binds from CamelMessage
to NettyHttpResponse
.
-
-
-
Method Detail
-
copy
public DefaultNettyHttpBinding copy()
-
toCamelMessage
public org.apache.camel.Message toCamelMessage(io.netty.handler.codec.http.FullHttpRequest request, org.apache.camel.Exchange exchange, NettyHttpConfiguration configuration) throws Exception
Description copied from interface:NettyHttpBinding
Binds from NettyHttpRequest
to CamelMessage
. Will use the populateCamelHeaders method for populating the headers.- Specified by:
toCamelMessage
in interfaceNettyHttpBinding
- Parameters:
request
- the netty http requestexchange
- the exchange that should contain the returned message.configuration
- the endpoint configuration- Returns:
- the message to store on the given exchange
- Throws:
Exception
- is thrown if error during binding
-
toCamelMessage
public org.apache.camel.Message toCamelMessage(InboundStreamHttpRequest request, org.apache.camel.Exchange exchange, NettyHttpConfiguration configuration) throws Exception
Description copied from interface:NettyHttpBinding
Binds from NettyInboundStreamHttpRequest
to CamelMessage
.- Specified by:
toCamelMessage
in interfaceNettyHttpBinding
- Parameters:
request
- the netty http requestexchange
- the exchange that should contain the returned message.configuration
- the endpoint configuration- Returns:
- the message to store on the given exchange
- Throws:
Exception
- is thrown if error during binding
-
populateCamelHeaders
public void populateCamelHeaders(io.netty.handler.codec.http.HttpRequest request, Map<String,Object> headers, org.apache.camel.Exchange exchange, NettyHttpConfiguration configuration) throws Exception
Description copied from interface:NettyHttpBinding
Binds from NettyHttpRequest
to Camel headers as aMap
. Will use the populateCamelHeaders method for populating the headers.- Specified by:
populateCamelHeaders
in interfaceNettyHttpBinding
- Parameters:
request
- the netty http requestheaders
- the Camel headers that should be populatedexchange
- the exchange that should contain the returned message.configuration
- the endpoint configuration- Throws:
Exception
- is thrown if error during binding
-
copyCamelHeaders
protected void copyCamelHeaders(Map<String,Object> headers, org.apache.camel.Exchange exchange)
Copy camel header from exchange to headers map.- Parameters:
headers
- the map headersexchange
- the exchange
-
shouldUrlDecodeHeader
protected String shouldUrlDecodeHeader(NettyHttpConfiguration configuration, String headerName, Object value, String charset) throws UnsupportedEncodingException
Decodes the header if needed to, or returns the header value as is.- Parameters:
configuration
- the configurationheaderName
- the header namevalue
- the current header valuecharset
- the charset to use for decoding- Returns:
- the decoded value (if decoded was needed) or a toString representation of the value.
- Throws:
UnsupportedEncodingException
- is thrown if error decoding.
-
toCamelMessage
public org.apache.camel.Message toCamelMessage(io.netty.handler.codec.http.FullHttpResponse response, org.apache.camel.Exchange exchange, NettyHttpConfiguration configuration)
Description copied from interface:NettyHttpBinding
Binds from NettyHttpResponse
to CamelMessage
. Will use the populateCamelHeaders method for populating the headers.- Specified by:
toCamelMessage
in interfaceNettyHttpBinding
- Parameters:
response
- the netty http responseexchange
- the exchange that should contain the returned message.configuration
- the endpoint configuration- Returns:
- the message to store on the given exchange
-
toCamelMessage
public org.apache.camel.Message toCamelMessage(InboundStreamHttpResponse response, org.apache.camel.Exchange exchange, NettyHttpConfiguration configuration)
Description copied from interface:NettyHttpBinding
Binds from NettyInboundStreamHttpResponse
to CamelMessage
. Will use the populateCamelHeaders method for populating the headers.- Specified by:
toCamelMessage
in interfaceNettyHttpBinding
- Parameters:
response
- the netty http responseexchange
- the exchange that should contain the returned message.configuration
- the endpoint configuration- Returns:
- the message to store on the given exchange
-
populateCamelHeaders
public void populateCamelHeaders(io.netty.handler.codec.http.HttpResponse response, Map<String,Object> headers, org.apache.camel.Exchange exchange, NettyHttpConfiguration configuration)
Description copied from interface:NettyHttpBinding
Binds from NettyHttpResponse
to Camel headers as aMap
.- Specified by:
populateCamelHeaders
in interfaceNettyHttpBinding
- Parameters:
response
- the netty http responseheaders
- the Camel headers that should be populatedexchange
- the exchange that should contain the returned message.configuration
- the endpoint configuration
-
toNettyResponse
public io.netty.handler.codec.http.HttpResponse toNettyResponse(org.apache.camel.Message message, NettyHttpConfiguration configuration) throws Exception
Description copied from interface:NettyHttpBinding
Binds from CamelMessage
to NettyHttpResponse
.- Specified by:
toNettyResponse
in interfaceNettyHttpBinding
- Parameters:
message
- the Camel messageconfiguration
- the endpoint configuration- Returns:
- the http response
- Throws:
Exception
- is thrown if error during binding
-
toNettyRequest
public io.netty.handler.codec.http.HttpRequest toNettyRequest(org.apache.camel.Message message, String fullUri, NettyHttpConfiguration configuration) throws Exception
Description copied from interface:NettyHttpBinding
Binds from CamelMessage
to NettyHttpRequest
.- Specified by:
toNettyRequest
in interfaceNettyHttpBinding
- Parameters:
message
- the Camel messagefullUri
- the uri which is the intended uri to call, though the message may override the uriconfiguration
- the endpoint configuration- Returns:
- the http request
- Throws:
Exception
- is thrown if error during binding
-
getHeaderFilterStrategy
public org.apache.camel.spi.HeaderFilterStrategy getHeaderFilterStrategy()
Description copied from interface:NettyHttpBinding
Gets the header filter strategy- Specified by:
getHeaderFilterStrategy
in interfaceNettyHttpBinding
- Returns:
- the strategy
-
setHeaderFilterStrategy
public void setHeaderFilterStrategy(org.apache.camel.spi.HeaderFilterStrategy headerFilterStrategy)
Description copied from interface:NettyHttpBinding
Sets the header filter strategy to use.- Specified by:
setHeaderFilterStrategy
in interfaceNettyHttpBinding
- Parameters:
headerFilterStrategy
- the custom strategy
-
-