org.apache.hc.client5.http.methods

## Class HttpRequestWrapper

- java.lang.Object
- - org.apache.hc.core5.http.message.HeaderGroup
  - - org.apache.hc.core5.http.message.AbstractHttpMessage
    - - org.apache.hc.client5.http.methods.HttpRequestWrapper

All Implemented Interfaces:
  Serializable, HttpUriRequest, org.apache.hc.core5.http.HttpMessage<org.apache.hc.core5.http.HttpEntity>, org.apache.hc.core5.http.HttpRequest, org.apache.hc.core5.http.MessageHead

    @NotThreadSafe
    public class HttpRequestWrapper
    extends org.apache.hc.core5.http.message.AbstractHttpMessage
    implements HttpUriRequest

A wrapper class for `HttpRequest` that can be used to change properties of the current request without modifying the original object.

Since:
  4.3
See Also:
  Serialized Form

### Method Summary

Methods
`void` `abort()` Aborts execution of the request.
`org.apache.hc.core5.http.HttpEntity` `getEntity()`
`String` `getMethod()` Returns the HTTP method this request uses, such as `GET`, `PUT`, `POST`, or other.
`org.apache.hc.core5.http.HttpRequest` `getOriginal()`
`org.apache.hc.core5.http.ProtocolVersion` `getProtocolVersion()`
`org.apache.hc.core5.http.RequestLine` `getRequestLine()`
`org.apache.hc.core5.http.HttpHost` `getTarget()`
`URI` `getURI()` Returns the URI this request uses, such as `http://example.org/path/to/file`.
`boolean` `isAborted()` Tests if the request execution has been aborted.
`void` `setEntity(org.apache.hc.core5.http.HttpEntity entity)`
`void` `setProtocolVersion(org.apache.hc.core5.http.ProtocolVersion version)`
`void` `setURI(URI uri)`
`String` `toString()`
`static HttpRequestWrapper` `wrap(org.apache.hc.core5.http.HttpRequest request, org.apache.hc.core5.http.HttpHost target)` Creates a mutable wrapper of the original request.

### Methods inherited from class org.apache.hc.core5.http.message.AbstractHttpMessage

`addHeader, setHeader`

### Methods inherited from class org.apache.hc.core5.http.message.HeaderGroup

`addHeader, clear, containsHeader, containsHeaders, getAllHeaders, getCondensedHeader, getFirstHeader, getHeaders, getLastHeader, headerIterator, headerIterator, removeHeader, removeHeaders, setHeader, setHeaders`

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

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

### Methods inherited from interface org.apache.hc.core5.http.HttpMessage

`addHeader, addHeader, removeHeader, removeHeaders, setHeader, setHeader, setHeaders`

### Methods inherited from interface org.apache.hc.core5.http.MessageHead

`containsHeader, containsHeaders, getAllHeaders, getFirstHeader, getHeaders, getLastHeader, headerIterator, headerIterator`

### Method Detail

#### getProtocolVersion

    public org.apache.hc.core5.http.ProtocolVersion getProtocolVersion()

Specified by:
  `getProtocolVersion` in interface `org.apache.hc.core5.http.HttpMessage<org.apache.hc.core5.http.HttpEntity>`

#### setProtocolVersion

    public void setProtocolVersion(org.apache.hc.core5.http.ProtocolVersion version)

#### getURI

    public URI getURI()

Description copied from interface: `HttpUriRequest`
Returns the URI this request uses, such as `http://example.org/path/to/file`.

Note that the URI may be absolute URI (as above) or may be a relative URI.

Implementations are encouraged to return the URI that was initially requested.

To find the final URI after any redirects have been processed, please see the section entitled HTTP execution context in the HttpClient Tutorial

Specified by:
  `getURI` in interface `HttpUriRequest`

#### setURI

    public void setURI(URI uri)

#### getMethod

    public String getMethod()

Description copied from interface: `HttpUriRequest`
Returns the HTTP method this request uses, such as `GET`, `PUT`, `POST`, or other.

Specified by:
  `getMethod` in interface `HttpUriRequest`

#### abort

    public void abort()
               throws UnsupportedOperationException

Description copied from interface: `HttpUriRequest`
Aborts execution of the request.

Specified by:
  `abort` in interface `HttpUriRequest`
Throws:
  `UnsupportedOperationException` - if the abort operation is not supported / cannot be implemented.

#### isAborted

    public boolean isAborted()

Description copied from interface: `HttpUriRequest`
Tests if the request execution has been aborted.

Specified by:
  `isAborted` in interface `HttpUriRequest`
Returns:
  `true` if the request execution has been aborted, `false` otherwise.

#### getRequestLine

    public org.apache.hc.core5.http.RequestLine getRequestLine()

Specified by:
  `getRequestLine` in interface `org.apache.hc.core5.http.HttpRequest`

#### getEntity

    public org.apache.hc.core5.http.HttpEntity getEntity()

Specified by:
  `getEntity` in interface `org.apache.hc.core5.http.HttpMessage<org.apache.hc.core5.http.HttpEntity>`
Overrides:
  `getEntity` in class `org.apache.hc.core5.http.message.AbstractHttpMessage`

#### setEntity

    public void setEntity(org.apache.hc.core5.http.HttpEntity entity)

Specified by:
  `setEntity` in interface `org.apache.hc.core5.http.HttpMessage<org.apache.hc.core5.http.HttpEntity>`
Overrides:
  `setEntity` in class `org.apache.hc.core5.http.message.AbstractHttpMessage`

#### getOriginal

    public org.apache.hc.core5.http.HttpRequest getOriginal()

#### getTarget

    public org.apache.hc.core5.http.HttpHost getTarget()

Since:
  4.4

#### toString

    public String toString()

Overrides:
  `toString` in class `org.apache.hc.core5.http.message.HeaderGroup`

#### wrap

    public static HttpRequestWrapper wrap(org.apache.hc.core5.http.HttpRequest request,
                          org.apache.hc.core5.http.HttpHost target)

Creates a mutable wrapper of the original request.

Parameters:
  `request` - original request
Returns:
  mutable request wrappering the original one