public final class

BasicHttpProcessor

extends Object
implements Cloneable HttpProcessor HttpRequestInterceptorList HttpResponseInterceptorList
java.lang.Object
   ↳ org.apache.http.protocol.BasicHttpProcessor

Class Overview

Default implementation of HttpProcessor.

Please note access to the internal structures of this class is not synchronized and therefore this class may be thread-unsafe.

Summary

Fields
protected final List requestInterceptors
protected final List responseInterceptors
Public Constructors
BasicHttpProcessor()
Public Methods
final void addInterceptor(HttpRequestInterceptor interceptor, int index)
final void addInterceptor(HttpResponseInterceptor interceptor, int index)
final void addInterceptor(HttpRequestInterceptor interceptor)
final void addInterceptor(HttpResponseInterceptor interceptor)
void addRequestInterceptor(HttpRequestInterceptor itcp, int index)
Inserts a request interceptor at the specified index.
void addRequestInterceptor(HttpRequestInterceptor itcp)
Appends a request interceptor to this list.
void addResponseInterceptor(HttpResponseInterceptor itcp, int index)
Inserts a response interceptor at the specified index.
void addResponseInterceptor(HttpResponseInterceptor itcp)
Appends a response interceptor to this list.
void clearInterceptors()
Clears both interceptor lists maintained by this processor.
void clearRequestInterceptors()
Removes all request interceptors from this list.
void clearResponseInterceptors()
Removes all response interceptors from this list.
Object clone()
BasicHttpProcessor copy()
Creates a copy of this instance
HttpRequestInterceptor getRequestInterceptor(int index)
Obtains a request interceptor from this list.
int getRequestInterceptorCount()
Obtains the current size of this list.
HttpResponseInterceptor getResponseInterceptor(int index)
Obtains a response interceptor from this list.
int getResponseInterceptorCount()
Obtains the current size of this list.
void process(HttpResponse response, HttpContext context)
Processes a response.
void process(HttpRequest request, HttpContext context)
Processes a request.
void removeRequestInterceptorByClass(Class clazz)
Removes all request interceptor of the specified class
void removeResponseInterceptorByClass(Class clazz)
Removes all response interceptor of the specified class
void setInterceptors(List list)
Sets the interceptor lists.
Protected Methods
void copyInterceptors(BasicHttpProcessor target)
Sets up the target to have the same list of interceptors as the current instance.
[Expand]
Inherited Methods
From class java.lang.Object
From interface org.apache.http.HttpRequestInterceptor
From interface org.apache.http.HttpResponseInterceptor
From interface org.apache.http.protocol.HttpRequestInterceptorList
From interface org.apache.http.protocol.HttpResponseInterceptorList

Fields

protected final List requestInterceptors

protected final List responseInterceptors

Public Constructors

public BasicHttpProcessor ()

Public Methods

public final void addInterceptor (HttpRequestInterceptor interceptor, int index)

public final void addInterceptor (HttpResponseInterceptor interceptor, int index)

public final void addInterceptor (HttpRequestInterceptor interceptor)

public final void addInterceptor (HttpResponseInterceptor interceptor)

public void addRequestInterceptor (HttpRequestInterceptor itcp, int index)

Inserts a request interceptor at the specified index.

Parameters
itcp the request interceptor to add
index the index to insert the interceptor at

public void addRequestInterceptor (HttpRequestInterceptor itcp)

Appends a request interceptor to this list.

Parameters
itcp the request interceptor to add

public void addResponseInterceptor (HttpResponseInterceptor itcp, int index)

Inserts a response interceptor at the specified index.

Parameters
itcp the response interceptor to add
index the index to insert the interceptor at

public void addResponseInterceptor (HttpResponseInterceptor itcp)

Appends a response interceptor to this list.

Parameters
itcp the response interceptor to add

public void clearInterceptors ()

Clears both interceptor lists maintained by this processor.

public void clearRequestInterceptors ()

Removes all request interceptors from this list.

public void clearResponseInterceptors ()

Removes all response interceptors from this list.

public Object clone ()

public BasicHttpProcessor copy ()

Creates a copy of this instance

Returns
  • new instance of the BasicHttpProcessor

public HttpRequestInterceptor getRequestInterceptor (int index)

Obtains a request interceptor from this list.

Parameters
index the index of the interceptor to obtain, 0 for first
Returns
  • the interceptor at the given index, or null if the index is out of range

public int getRequestInterceptorCount ()

Obtains the current size of this list.

Returns
  • the number of request interceptors in this list

public HttpResponseInterceptor getResponseInterceptor (int index)

Obtains a response interceptor from this list.

Parameters
index the index of the interceptor to obtain, 0 for first
Returns
  • the interceptor at the given index, or null if the index is out of range

public int getResponseInterceptorCount ()

Obtains the current size of this list.

Returns
  • the number of response interceptors in this list

public void process (HttpResponse response, HttpContext context)

Processes a response. On the server side, this step is performed before the response is sent to the client. On the client side, this step is performed on incoming messages before the message body is evaluated.

Parameters
response the response to postprocess
context the context for the request

public void process (HttpRequest request, HttpContext context)

Processes a request. On the client side, this step is performed before the request is sent to the server. On the server side, this step is performed on incoming messages before the message body is evaluated.

Parameters
request the request to preprocess
context the context for the request

public void removeRequestInterceptorByClass (Class clazz)

Removes all request interceptor of the specified class

Parameters
clazz the class of the instances to be removed.

public void removeResponseInterceptorByClass (Class clazz)

Removes all response interceptor of the specified class

Parameters
clazz the class of the instances to be removed.

public void setInterceptors (List list)

Sets the interceptor lists. First, both interceptor lists maintained by this processor will be cleared. Subsequently, elements of the argument list that are request interceptors will be added to the request interceptor list. Elements that are response interceptors will be added to the response interceptor list. Elements that are both request and response interceptor will be added to both lists. Elements that are neither request nor response interceptor will be ignored.

Parameters
list the list of request and response interceptors from which to initialize

Protected Methods

protected void copyInterceptors (BasicHttpProcessor target)

Sets up the target to have the same list of interceptors as the current instance.

Parameters
target object to be initialised