Package org.springframework.http.client.support

# Class InterceptingHttpAccessor

java.lang.Object
org.springframework.http.client.support.HttpAccessor
org.springframework.http.client.support.InterceptingHttpAccessor

Direct Known Subclasses:
  `RestTemplate`

public abstract class InterceptingHttpAccessor extends HttpAccessor
Base class for `RestTemplate` and other HTTP accessing gateway helpers, adding interceptor-related properties to `HttpAccessor`'s common properties.

Not intended to be used directly. See `RestTemplate` for an entry point.

Since:
  3.0
Author:
  Arjen Poutsma, Juergen Hoeller
See Also:
  - `ClientHttpRequestInterceptor`
  - `InterceptingClientHttpRequestFactory`
  - `RestTemplate`

## Field Summary

### Fields inherited from class org.springframework.http.client.support.HttpAccessor

`logger`

## Constructor Summary

Constructors
Constructor
Description
`InterceptingHttpAccessor()`

## Method Summary

Modifier and Type
Method
Description
`List<ClientHttpRequestInterceptor>`
`getInterceptors()`
Get the request interceptors that this accessor uses.
`ClientHttpRequestFactory`
`getRequestFactory()`
Overridden to expose an `InterceptingClientHttpRequestFactory` if necessary.
`void`
`setInterceptors(List<ClientHttpRequestInterceptor> interceptors)`
Set the request interceptors that this accessor should use.
`void`
`setRequestFactory(ClientHttpRequestFactory requestFactory)`
Set the request factory that this accessor uses for obtaining client request handles.

### Methods inherited from class org.springframework.http.client.support.HttpAccessor

`createRequest, getClientHttpRequestInitializers, setClientHttpRequestInitializers`

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

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

## Constructor Details

### InterceptingHttpAccessor

public InterceptingHttpAccessor()

## Method Details

### setInterceptors

public void setInterceptors(List<ClientHttpRequestInterceptor> interceptors)
Set the request interceptors that this accessor should use.

The interceptors will get immediately sorted according to their order.

Note: This method does not support concurrent changes, and in most cases should not be called after initialization on startup. See also related note on `RestTemplate` regarding concurrent configuration changes.

See Also:
  - `getRequestFactory()`
  - `AnnotationAwareOrderComparator`

### getInterceptors

public List<ClientHttpRequestInterceptor> getInterceptors()
Get the request interceptors that this accessor uses.

The returned `List` is active and may be modified. Note, however, that the interceptors will not be resorted according to their order before the `ClientHttpRequestFactory` is built.

### setRequestFactory

public void setRequestFactory(ClientHttpRequestFactory requestFactory)
Description copied from class: `HttpAccessor`
Set the request factory that this accessor uses for obtaining client request handles.

The default is a `SimpleClientHttpRequestFactory` based on the JDK's own HTTP libraries (`HttpURLConnection`).

Note that the standard JDK HTTP library does not support the HTTP PATCH method. Configure the Apache HttpComponents or OkHttp request factory to enable PATCH.

Overrides:
  `setRequestFactory` in class `HttpAccessor`
See Also:
  - `HttpAccessor.createRequest(URI, HttpMethod)`
  - `SimpleClientHttpRequestFactory`
  - `HttpComponentsClientHttpRequestFactory`
  - `JdkClientHttpRequestFactory`

### getRequestFactory

public ClientHttpRequestFactory getRequestFactory()
Overridden to expose an `InterceptingClientHttpRequestFactory` if necessary.

Overrides:
  `getRequestFactory` in class `HttpAccessor`
See Also:
  - `getInterceptors()`