Class NettyHttpConfiguration

java.lang.Object
org.apache.camel.component.netty.NettyServerBootstrapConfiguration
org.apache.camel.component.netty.NettyConfiguration
org.apache.camel.component.netty.http.NettyHttpConfiguration
All Implemented Interfaces:
Cloneable

@UriParams @Configurer public class NettyHttpConfiguration extends org.apache.camel.component.netty.NettyConfiguration
Extended configuration for using HTTP with Netty.
  • Field Summary

    Fields inherited from class org.apache.camel.component.netty.NettyServerBootstrapConfiguration

    backlog, bossCount, bossGroup, broadcast, channelGroup, connectTimeout, DEFAULT_ENABLED_PROTOCOLS, enabledProtocols, keepAlive, keyStoreFile, keyStoreFormat, keyStoreResource, nativeTransport, needClientAuth, nettyServerBootstrapFactory, networkInterface, options, passphrase, port, receiveBufferSize, receiveBufferSizePredictor, reuseAddress, securityProvider, sendBufferSize, serverInitializerFactory, ssl, sslClientCertHeaders, sslContextParameters, sslHandler, tcpNoDelay, trustStoreFile, trustStoreResource, workerCount, workerGroup
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
     
    int
     
     
    int
     
    int
     
    int
     
     
     
    int
     
     
    boolean
     
    boolean
     
    boolean
     
    boolean
     
    boolean
     
    boolean
     
    boolean
     
    boolean
     
    boolean
     
    boolean
     
    boolean
     
    boolean
     
    boolean
     
    boolean
     
    void
    setBridgeEndpoint(boolean bridgeEndpoint)
    If the option is true, the producer will ignore the NettyHttpConstants.HTTP_URI header, and use the endpoint's URI for request.
    void
    setChunkedMaxContentLength(int chunkedMaxContentLength)
    Value in bytes the max content length per chunked frame received on the Netty HTTP server.
    void
    setCompression(boolean compression)
    Allow using gzip/deflate for compression on the Netty HTTP server if the client supports it from the HTTP headers.
    void
    setDisableStreamCache(boolean disableStreamCache)
    Determines whether or not the raw input stream from Netty HttpRequest#getContent() or HttpResponset#getContent() is cached or not (Camel will read the stream into a in light-weight memory based Stream caching) cache.
    void
    The local hostname such as localhost, or 0.0.0.0 when being a consumer.
    void
    setLogWarnOnBadRequest(boolean logWarnOnBadRequest)
    Whether Netty HTTP server should log a WARN if decoding the HTTP request failed and a HTTP Status 400 (bad request) is returned.
    void
    setMapHeaders(boolean mapHeaders)
    If this option is enabled, then during binding from Netty to Camel Message then the headers will be mapped as well (eg added as header to the Camel Message as well).
    void
    setMatchOnUriPrefix(boolean matchOnUriPrefix)
    Whether or not Camel should try to find a target consumer by matching the URI prefix if no exact match is found.
    void
    setMaxChunkSize(int maxChunkSize)
    The maximum length of the content or each chunk.
    void
    setMaxHeaderSize(int maxHeaderSize)
    The maximum length of all headers.
    void
    setMaxInitialLineLength(int maxInitialLineLength)
    The maximum length of the initial line (e.g.
    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
    setOkStatusCodeRange(String okStatusCodeRange)
    The status codes which are considered a success response.
    void
    Resource path
    void
    setPort(int port)
    The port number.
    void
    setProtocol(String protocol)
    The protocol to use which is either http, https or proxy - a consumer only option.
    void
    setSend503whenSuspended(boolean send503whenSuspended)
    Whether to send back HTTP status code 503 when the consumer has been suspended.
    void
    setSynchronous(boolean synchronous)
     
    void
    setThrowExceptionOnFailure(boolean throwExceptionOnFailure)
    Option to disable throwing the HttpOperationFailedException in case of failed responses from the remote server.
    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.
    void
    setUrlDecodeHeaders(boolean urlDecodeHeaders)
    If this option is enabled, then during binding from Netty to Camel Message then the header values will be URL decoded (eg %20 will be a space character.
    void
    setUseRelativePath(boolean useRelativePath)
    Sets whether to use a relative path in HTTP requests.

    Methods inherited from class org.apache.camel.component.netty.NettyConfiguration

    addDecoder, addEncoder, getCharsetName, getClientInitializerFactory, getClientPipelineFactory, getCorrelationManager, getDecoderMaxLineLength, getDecoders, getDecodersAsList, getDelimiter, getEncoders, getEncodersAsList, getEncoding, getNoReplyLogLevel, getProducerPoolMaxIdle, getProducerPoolMaxTotal, getProducerPoolMaxWait, getProducerPoolMinEvictableIdle, getProducerPoolMinIdle, getRequestTimeout, getServerClosedChannelExceptionCaughtLogLevel, getServerExceptionCaughtLogLevel, isAllowDefaultCodec, isAllowSerializedHeaders, isAutoAppendDelimiter, isClientMode, isDisconnect, isDisconnectOnNoReply, isHostnameVerification, isLazyChannelCreation, isProducerPoolBlockWhenExhausted, isProducerPoolEnabled, isReuseChannel, isSync, isTextline, isTransferExchange, isUdpByteArrayCodec, isUdpConnectionlessSending, isUseByteBuf, isUsingExecutorService, parseURI, setAllowDefaultCodec, setAllowSerializedHeaders, setAutoAppendDelimiter, setClientInitializerFactory, setClientMode, setClientPipelineFactory, setCorrelationManager, setDecoderMaxLineLength, setDecoders, setDecoders, setDecodersAsList, setDelimiter, setDisconnect, setDisconnectOnNoReply, setEncoders, setEncoders, setEncodersAsList, setEncoding, setHostnameVerification, setLazyChannelCreation, setNoReplyLogLevel, setProducerPoolBlockWhenExhausted, setProducerPoolEnabled, setProducerPoolMaxIdle, setProducerPoolMaxTotal, setProducerPoolMaxWait, setProducerPoolMinEvictableIdle, setProducerPoolMinIdle, setRequestTimeout, setReuseChannel, setServerClosedChannelExceptionCaughtLogLevel, setServerExceptionCaughtLogLevel, setSync, setTextline, setTransferExchange, setUdpByteArrayCodec, setUdpConnectionlessSending, setUseByteBuf, setUsingExecutorService, validateConfiguration

    Methods inherited from class org.apache.camel.component.netty.NettyServerBootstrapConfiguration

    compatible, getAddress, getBacklog, getBossCount, getBossGroup, getChannelGroup, getConnectTimeout, getEnabledProtocols, getKeyStoreFile, getKeyStoreFormat, getKeyStoreResource, getNettyServerBootstrapFactory, getNetworkInterface, getOptions, getPassphrase, getReceiveBufferSize, getReceiveBufferSizePredictor, getReconnectInterval, getSecurityProvider, getSendBufferSize, getServerInitializerFactory, getServerPipelineFactory, getSslContextParameters, getSslHandler, getTrustStoreFile, getTrustStoreResource, getUnixDomainSocketPath, getWorkerCount, getWorkerGroup, isBroadcast, isKeepAlive, isNativeTransport, isNeedClientAuth, isReconnect, isReuseAddress, isSsl, isSslClientCertHeaders, isTcp, isTcpNoDelay, setBacklog, setBossCount, setBossGroup, setBroadcast, setChannelGroup, setConnectTimeout, setEnabledProtocols, setKeepAlive, setKeyStoreFile, setKeyStoreFormat, setKeyStoreResource, setNativeTransport, setNeedClientAuth, setNettyServerBootstrapFactory, setNetworkInterface, setOptions, setPassphrase, setReceiveBufferSize, setReceiveBufferSizePredictor, setReconnect, setReconnectInterval, setReuseAddress, setSecurityProvider, setSendBufferSize, setServerInitializerFactory, setServerPipelineFactory, setSsl, setSslClientCertHeaders, setSslContextParameters, setSslHandler, setTcpNoDelay, setTrustStoreFile, setTrustStoreResource, setUnixDomainSocketPath, setWorkerCount, setWorkerGroup, toStringBootstrapConfiguration

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • NettyHttpConfiguration

      public NettyHttpConfiguration()
  • Method Details

    • copy

      public NettyHttpConfiguration copy()
      Overrides:
      copy in class org.apache.camel.component.netty.NettyConfiguration
    • getProtocol

      public String getProtocol()
      Overrides:
      getProtocol in class org.apache.camel.component.netty.NettyServerBootstrapConfiguration
    • setProtocol

      public void setProtocol(String protocol)
      The protocol to use which is either http, https or proxy - a consumer only option.
      Overrides:
      setProtocol in class org.apache.camel.component.netty.NettyServerBootstrapConfiguration
    • getHost

      public String getHost()
      Overrides:
      getHost in class org.apache.camel.component.netty.NettyServerBootstrapConfiguration
    • setHost

      public void setHost(String host)
      The local hostname such as localhost, or 0.0.0.0 when being a consumer. The remote HTTP server hostname when using producer.
      Overrides:
      setHost in class org.apache.camel.component.netty.NettyServerBootstrapConfiguration
    • getPort

      public int getPort()
      Overrides:
      getPort in class org.apache.camel.component.netty.NettyServerBootstrapConfiguration
    • setPort

      public void setPort(int port)
      The port number. Is default 80 for http and 443 for https.
      Overrides:
      setPort in class org.apache.camel.component.netty.NettyServerBootstrapConfiguration
    • isCompression

      public boolean isCompression()
    • setCompression

      public void setCompression(boolean compression)
      Allow using gzip/deflate for compression on the Netty HTTP server if the client supports it from the HTTP headers.
    • isThrowExceptionOnFailure

      public boolean isThrowExceptionOnFailure()
    • setThrowExceptionOnFailure

      public void setThrowExceptionOnFailure(boolean throwExceptionOnFailure)
      Option to disable throwing the HttpOperationFailedException in case of failed responses from the remote server. This allows you to get all responses regardless of the HTTP status code.
    • isTransferException

      public boolean isTransferException()
    • setTransferException

      public 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. 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.

    • isMuteException

      public boolean isMuteException()
    • setMuteException

      public 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.
    • isUrlDecodeHeaders

      public boolean isUrlDecodeHeaders()
    • setUrlDecodeHeaders

      public void setUrlDecodeHeaders(boolean urlDecodeHeaders)
      If this option is enabled, then during binding from Netty to Camel Message then the header values will be URL decoded (eg %20 will be a space character. Notice this option is used by the default org.apache.camel.component.netty.http.NettyHttpBinding and therefore if you implement a custom org.apache.camel.component.netty.http.NettyHttpBinding then you would need to decode the headers accordingly to this option.
    • isMapHeaders

      public boolean isMapHeaders()
    • setMapHeaders

      public void setMapHeaders(boolean mapHeaders)
      If this option is enabled, then during binding from Netty to Camel Message then the headers will be mapped as well (eg added as header to the Camel Message as well). You can turn off this option to disable this. The headers can still be accessed from the org.apache.camel.component.netty.http.NettyHttpMessage message with the method getHttpRequest() that returns the Netty HTTP request io.netty.handler.codec.http.HttpRequest instance.
    • isMatchOnUriPrefix

      public boolean isMatchOnUriPrefix()
    • setMatchOnUriPrefix

      public void setMatchOnUriPrefix(boolean matchOnUriPrefix)
      Whether or not Camel should try to find a target consumer by matching the URI prefix if no exact match is found.
    • isLogWarnOnBadRequest

      public boolean isLogWarnOnBadRequest()
    • setLogWarnOnBadRequest

      public void setLogWarnOnBadRequest(boolean logWarnOnBadRequest)
      Whether Netty HTTP server should log a WARN if decoding the HTTP request failed and a HTTP Status 400 (bad request) is returned.
    • isBridgeEndpoint

      public boolean isBridgeEndpoint()
    • setBridgeEndpoint

      public void setBridgeEndpoint(boolean bridgeEndpoint)
      If the option is true, the producer will ignore the NettyHttpConstants.HTTP_URI header, and use the endpoint's URI for request. You may also set the throwExceptionOnFailure to be false to let the producer send all the fault response back. The consumer working in the bridge mode will skip the gzip compression and WWW URL form encoding (by adding the Exchange.SKIP_GZIP_ENCODING and Exchange.SKIP_WWW_FORM_URLENCODED headers to the consumed exchange).
    • getPath

      public String getPath()
    • setPath

      public void setPath(String path)
      Resource path
    • isDisableStreamCache

      public boolean isDisableStreamCache()
    • setDisableStreamCache

      public void setDisableStreamCache(boolean disableStreamCache)
      Determines whether or not the raw input stream from Netty HttpRequest#getContent() or HttpResponset#getContent() is cached or not (Camel will read the stream into a in light-weight memory based Stream caching) cache. By default Camel will cache the Netty input stream to support reading it multiple times to ensure it Camel can retrieve all data from the stream. However you can set this option to true when you for example need to access the raw stream, such as streaming it directly to a file or other persistent store. Mind that if you enable this option, then you cannot read the Netty stream multiple times out of the box, and you would need manually to reset the reader index on the Netty raw stream. Also Netty will auto-close the Netty stream when the Netty HTTP server/HTTP client is done processing, which means that if the asynchronous routing engine is in use then any asynchronous thread that may continue routing the Exchange may not be able to read the Netty stream, because Netty has closed it.
    • isSend503whenSuspended

      public boolean isSend503whenSuspended()
    • setSend503whenSuspended

      public void setSend503whenSuspended(boolean send503whenSuspended)
      Whether to send back HTTP status code 503 when the consumer has been suspended. If the option is false then the Netty Acceptor is unbound when the consumer is suspended, so clients cannot connect anymore.
    • getChunkedMaxContentLength

      public int getChunkedMaxContentLength()
    • setChunkedMaxContentLength

      public void setChunkedMaxContentLength(int chunkedMaxContentLength)
      Value in bytes the max content length per chunked frame received on the Netty HTTP server.
    • getMaxHeaderSize

      public int getMaxHeaderSize()
    • setMaxInitialLineLength

      public void setMaxInitialLineLength(int maxInitialLineLength)
      The maximum length of the initial line (e.g. "GET / HTTP/1.0" or "HTTP/1.0 200 OK") If the length of the initial line exceeds this value, a
      invalid reference
      TooLongFrameException
      will be raised. See HttpObjectDecoder
    • getMaxInitialLineLength

      public int getMaxInitialLineLength()
    • setMaxChunkSize

      public void setMaxChunkSize(int maxChunkSize)
      The maximum length of the content or each chunk. If the content length (or the length of each chunk) exceeds this value, the content or chunk will be split into multiple HttpContents whose length is maxChunkSize at maximum. See HttpObjectDecoder
    • getMaxChunkSize

      public int getMaxChunkSize()
    • setMaxHeaderSize

      public void setMaxHeaderSize(int maxHeaderSize)
      The maximum length of all headers. If the sum of the length of each header exceeds this value, a TooLongFrameException will be raised.
    • getOkStatusCodeRange

      public String getOkStatusCodeRange()
    • setOkStatusCodeRange

      public void setOkStatusCodeRange(String okStatusCodeRange)
      The status codes which are considered a success response. The values are inclusive. Multiple ranges can be defined, separated by comma, e.g. 200-204,209,301-304. Each range must be a single number or from-to with the dash included.

      The default range is 200-299

    • setUseRelativePath

      public void setUseRelativePath(boolean useRelativePath)
      Sets whether to use a relative path in HTTP requests.
    • isUseRelativePath

      public boolean isUseRelativePath()
    • isHttpProxy

      public boolean isHttpProxy()
    • isSynchronous

      public boolean isSynchronous()
    • setSynchronous

      public void setSynchronous(boolean synchronous)