org.springframework.http.client

## Class Netty4ClientHttpRequestFactory

- java.lang.Object
- - org.springframework.http.client.Netty4ClientHttpRequestFactory

- All Implemented Interfaces:
    DisposableBean, InitializingBean, AsyncClientHttpRequestFactory, ClientHttpRequestFactory

  Deprecated.
  as of Spring 5.0, in favor of `ReactorClientHttpConnector`

      @Deprecated
      public class Netty4ClientHttpRequestFactory
      extends Object
      implements ClientHttpRequestFactory, AsyncClientHttpRequestFactory, InitializingBean, DisposableBean

  `ClientHttpRequestFactory` implementation that uses Netty 4 to create requests.

  Allows to use a pre-configured `EventLoopGroup` instance: useful for sharing across multiple clients.

  Note that this implementation consistently closes the HTTP connection on each request.

  Since:
    4.1.2
  Author:
    Arjen Poutsma, Rossen Stoyanchev, Brian Clozel, Mark Paluch

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static int` | `DEFAULT_MAX_RESPONSE_SIZE` Deprecated. The default maximum response size.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `Netty4ClientHttpRequestFactory()` Deprecated. Create a new `Netty4ClientHttpRequestFactory` with a default `NioEventLoopGroup`.
    `Netty4ClientHttpRequestFactory(io.netty.channel.EventLoopGroup eventLoopGroup)` Deprecated. Create a new `Netty4ClientHttpRequestFactory` with the given `EventLoopGroup`.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods Deprecated Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `afterPropertiesSet()` Deprecated. Invoked by the containing `BeanFactory` after it has set all bean properties and satisfied `BeanFactoryAware`, `ApplicationContextAware` etc.
    `protected void` | `configureChannel(io.netty.channel.socket.SocketChannelConfig config)` Deprecated. Template method for changing properties on the given `SocketChannelConfig`.
    `AsyncClientHttpRequest` | `createAsyncRequest(URI uri, HttpMethod httpMethod)` Deprecated. Create a new asynchronous `AsyncClientHttpRequest` for the specified URI and HTTP method.
    `ClientHttpRequest` | `createRequest(URI uri, HttpMethod httpMethod)` Deprecated. Create a new `ClientHttpRequest` for the specified URI and HTTP method.
    `void` | `destroy()` Deprecated. Invoked by the containing `BeanFactory` on destruction of a bean.
    `void` | `setConnectTimeout(int connectTimeout)` Deprecated. Set the underlying connect timeout (in milliseconds).
    `void` | `setMaxResponseSize(int maxResponseSize)` Deprecated. Set the default maximum response size.
    `void` | `setReadTimeout(int readTimeout)` Deprecated. Set the underlying URLConnection's read timeout (in milliseconds).
    `void` | `setSslContext(io.netty.handler.ssl.SslContext sslContext)` Deprecated. Set the SSL context.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### DEFAULT_MAX_RESPONSE_SIZE

          public static final int DEFAULT_MAX_RESPONSE_SIZE

      Deprecated.
      The default maximum response size.
      See Also:
        `setMaxResponseSize(int)`, Constant Field Values

  - ### Constructor Detail

    - #### Netty4ClientHttpRequestFactory

          public Netty4ClientHttpRequestFactory()

      Deprecated.
      Create a new `Netty4ClientHttpRequestFactory` with a default `NioEventLoopGroup`.

    - #### Netty4ClientHttpRequestFactory

          public Netty4ClientHttpRequestFactory(io.netty.channel.EventLoopGroup eventLoopGroup)

      Deprecated.
      Create a new `Netty4ClientHttpRequestFactory` with the given `EventLoopGroup`.

      NOTE: the given group will not be shutdown by this factory; doing so becomes the responsibility of the caller.

  - ### Method Detail

    - #### setMaxResponseSize

          public void setMaxResponseSize(int maxResponseSize)

      Deprecated.
      Set the default maximum response size.

      By default this is set to `DEFAULT_MAX_RESPONSE_SIZE`.

      Since:
        4.1.5
      See Also:
        `HttpObjectAggregator(int)`

    - #### setSslContext

          public void setSslContext(io.netty.handler.ssl.SslContext sslContext)

      Deprecated.
      Set the SSL context. When configured it is used to create and insert an `SslHandler` in the channel pipeline.

      A default client SslContext is configured if none has been provided.

    - #### setConnectTimeout

          public void setConnectTimeout(int connectTimeout)

      Deprecated.
      Set the underlying connect timeout (in milliseconds). A timeout value of 0 specifies an infinite timeout.
      See Also:
        `ChannelConfig.setConnectTimeoutMillis(int)`

    - #### setReadTimeout

          public void setReadTimeout(int readTimeout)

      Deprecated.
      Set the underlying URLConnection's read timeout (in milliseconds). A timeout value of 0 specifies an infinite timeout.
      See Also:
        `ReadTimeoutHandler`

    - #### afterPropertiesSet

          public void afterPropertiesSet()

      Deprecated.
      Description copied from interface: `InitializingBean`
      Invoked by the containing `BeanFactory` after it has set all bean properties and satisfied `BeanFactoryAware`, `ApplicationContextAware` etc.

      This method allows the bean instance to perform validation of its overall configuration and final initialization when all bean properties have been set.

      Specified by:
        `afterPropertiesSet` in interface `InitializingBean`

    - #### createRequest

          public ClientHttpRequest createRequest(URI uri,
                                                 HttpMethod httpMethod)
                                          throws IOException

      Deprecated.
      Description copied from interface: `ClientHttpRequestFactory`
      Create a new `ClientHttpRequest` for the specified URI and HTTP method.

      The returned request can be written to, and then executed by calling `ClientHttpRequest.execute()`.

      Specified by:
        `createRequest` in interface `ClientHttpRequestFactory`
      Parameters:
        `uri` - the URI to create a request for
        `httpMethod` - the HTTP method to execute
      Returns:
        the created request
      Throws:
        `IOException` - in case of I/O errors

    - #### createAsyncRequest

          public AsyncClientHttpRequest createAsyncRequest(URI uri,
                                                           HttpMethod httpMethod)
                                                    throws IOException

      Deprecated.
      Description copied from interface: `AsyncClientHttpRequestFactory`
      Create a new asynchronous `AsyncClientHttpRequest` for the specified URI and HTTP method.

      The returned request can be written to, and then executed by calling `AsyncClientHttpRequest.executeAsync()`.

      Specified by:
        `createAsyncRequest` in interface `AsyncClientHttpRequestFactory`
      Parameters:
        `uri` - the URI to create a request for
        `httpMethod` - the HTTP method to execute
      Returns:
        the created request
      Throws:
        `IOException` - in case of I/O errors

    - #### configureChannel

          protected void configureChannel(io.netty.channel.socket.SocketChannelConfig config)

      Deprecated.
      Template method for changing properties on the given `SocketChannelConfig`.

      The default implementation sets the connect timeout based on the set property.

      Parameters:
        `config` - the channel configuration

    - #### destroy

          public void destroy()
                       throws InterruptedException

      Deprecated.
      Description copied from interface: `DisposableBean`
      Invoked by the containing `BeanFactory` on destruction of a bean.
      Specified by:
        `destroy` in interface `DisposableBean`
      Throws:
        `InterruptedException`