Package org.htmlunit.util

# Class WebConnectionWrapper

java.lang.Object
org.htmlunit.util.WebConnectionWrapper

All Implemented Interfaces:
  `AutoCloseable`, `WebConnection`

Direct Known Subclasses:
  `DebuggingWebConnection`, `FalsifyingWebConnection`

public class WebConnectionWrapper extends Object implements WebConnection

Provides a convenient implementation of the `WebConnection` interface that can be subclassed by developers wishing to adapt a particular WebConnection.

This class implements the Wrapper or Decorator pattern. Methods default to calling through to the wrapped web connection object.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `WebConnectionWrapper(WebClient webClient)`
  Constructs a WebConnection object wrapping the connection of the WebClient and places itself as connection of the WebClient.
  `WebConnectionWrapper(WebConnection webConnection)`
  Constructs a WebConnection object wrapping provided WebConnection.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `close()`
  The default behavior of this method is to return `WebConnection.close()` on the wrapped connection object.
  `WebResponse`
  `getResponse(WebRequest request)`
  Submits a request and retrieves a response.
  `WebConnection`
  `getWrappedWebConnection()`
  Gets the wrapped `WebConnection`.

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

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

- ## Constructor Details

  - ### WebConnectionWrapper

    public WebConnectionWrapper(WebConnection webConnection) throws IllegalArgumentException
    Constructs a WebConnection object wrapping provided WebConnection.
    Parameters:
      `webConnection` - the webConnection that does the real work
    Throws:
      `IllegalArgumentException` - if the connection is `null`

  - ### WebConnectionWrapper

    public WebConnectionWrapper(WebClient webClient) throws IllegalArgumentException
    Constructs a WebConnection object wrapping the connection of the WebClient and places itself as connection of the WebClient.
    Parameters:
      `webClient` - the WebClient which WebConnection should be wrapped
    Throws:
      `IllegalArgumentException` - if the WebClient is `null`

- ## Method Details

  - ### getResponse

    public WebResponse getResponse(WebRequest request) throws IOException
    Submits a request and retrieves a response. The default behavior of this method is to return `WebConnection.getResponse(WebRequest)` on the wrapped connection object.
    Specified by:
      `getResponse` in interface `WebConnection`
    Parameters:
      `request` - the request
    Returns:
      the response to the request defined by the specified request
    Throws:
      `IOException` - if an IO error occurs

  - ### getWrappedWebConnection

    public WebConnection getWrappedWebConnection()
    Gets the wrapped `WebConnection`.
    Returns:
      the wrapped connection

  - ### close

    public void close() throws IOException
    The default behavior of this method is to return `WebConnection.close()` on the wrapped connection object.
    Specified by:
      `close` in interface `AutoCloseable`
    Specified by:
      `close` in interface `WebConnection`
    Throws:
      `IOException`