Package org.apache.http.protocol
Class BasicHttpProcessor
java.lang.Object
org.apache.http.protocol.BasicHttpProcessor
- All Implemented Interfaces:
Cloneable,HttpRequestInterceptor,HttpResponseInterceptor,HttpProcessor,HttpRequestInterceptorList,HttpResponseInterceptorList
public final class BasicHttpProcessor extends Object implements HttpProcessor, HttpRequestInterceptorList, HttpResponseInterceptorList, Cloneable
Keeps lists of interceptors for processing requests and responses.
- Since:
- 4.0
- Version:
- $Revision: 613298 $
- Author:
- Oleg Kalnichevski, Andrea Selva
-
Field Summary
Fields Modifier and Type Field Description protected ListrequestInterceptorsprotected ListresponseInterceptors -
Constructor Summary
Constructors Constructor Description BasicHttpProcessor() -
Method Summary
Modifier and Type Method Description voidaddInterceptor(HttpRequestInterceptor interceptor)Same asaddRequestInterceptor.voidaddInterceptor(HttpRequestInterceptor interceptor, int index)voidaddInterceptor(HttpResponseInterceptor interceptor)Same asaddResponseInterceptor.voidaddInterceptor(HttpResponseInterceptor interceptor, int index)voidaddRequestInterceptor(HttpRequestInterceptor itcp)Appends a request interceptor to this list.voidaddRequestInterceptor(HttpRequestInterceptor itcp, int index)Inserts a request interceptor at the specified index.voidaddResponseInterceptor(HttpResponseInterceptor itcp)Appends a response interceptor to this list.voidaddResponseInterceptor(HttpResponseInterceptor itcp, int index)Inserts a response interceptor at the specified index.voidclearInterceptors()Clears both interceptor lists maintained by this processor.voidclearRequestInterceptors()Removes all request interceptors from this list.voidclearResponseInterceptors()Removes all response interceptors from this list.Objectclone()Creates and returns a copy of thisObject.BasicHttpProcessorcopy()Creates a copy of this instanceprotected voidcopyInterceptors(BasicHttpProcessor target)HttpRequestInterceptorgetRequestInterceptor(int index)Obtains a request interceptor from this list.intgetRequestInterceptorCount()Obtains the current size of this list.HttpResponseInterceptorgetResponseInterceptor(int index)Obtains a response interceptor from this list.intgetResponseInterceptorCount()Obtains the current size of this list.voidprocess(HttpRequest request, HttpContext context)Processes a request.voidprocess(HttpResponse response, HttpContext context)Processes a response.voidremoveRequestInterceptorByClass(Class clazz)Removes all request interceptor of the specified classvoidremoveResponseInterceptorByClass(Class clazz)Removes all response interceptor of the specified classvoidsetInterceptors(List list)Sets the interceptor lists.
-
Field Details
-
requestInterceptors
-
responseInterceptors
-
-
Constructor Details
-
BasicHttpProcessor
public BasicHttpProcessor()
-
-
Method Details
-
addRequestInterceptor
Description copied from interface:HttpRequestInterceptorListAppends a request interceptor to this list.- Specified by:
addRequestInterceptorin interfaceHttpRequestInterceptorList- Parameters:
itcp- the request interceptor to add
-
addRequestInterceptor
Description copied from interface:HttpRequestInterceptorListInserts a request interceptor at the specified index.- Specified by:
addRequestInterceptorin interfaceHttpRequestInterceptorList- Parameters:
itcp- the request interceptor to addindex- the index to insert the interceptor at
-
addResponseInterceptor
Description copied from interface:HttpResponseInterceptorListInserts a response interceptor at the specified index.- Specified by:
addResponseInterceptorin interfaceHttpResponseInterceptorList- Parameters:
itcp- the response interceptor to addindex- the index to insert the interceptor at
-
removeRequestInterceptorByClass
Description copied from interface:HttpRequestInterceptorListRemoves all request interceptor of the specified class- Specified by:
removeRequestInterceptorByClassin interfaceHttpRequestInterceptorList- Parameters:
clazz- the class of the instances to be removed.
-
removeResponseInterceptorByClass
Description copied from interface:HttpResponseInterceptorListRemoves all response interceptor of the specified class- Specified by:
removeResponseInterceptorByClassin interfaceHttpResponseInterceptorList- Parameters:
clazz- the class of the instances to be removed.
-
addInterceptor
Same asaddRequestInterceptor.- Parameters:
interceptor- the interceptor to add
-
addInterceptor
-
getRequestInterceptorCount
public int getRequestInterceptorCount()Description copied from interface:HttpRequestInterceptorListObtains the current size of this list.- Specified by:
getRequestInterceptorCountin interfaceHttpRequestInterceptorList- Returns:
- the number of request interceptors in this list
-
getRequestInterceptor
Description copied from interface:HttpRequestInterceptorListObtains a request interceptor from this list.- Specified by:
getRequestInterceptorin interfaceHttpRequestInterceptorList- Parameters:
index- the index of the interceptor to obtain, 0 for first- Returns:
- the interceptor at the given index, or
nullif the index is out of range
-
clearRequestInterceptors
public void clearRequestInterceptors()Description copied from interface:HttpRequestInterceptorListRemoves all request interceptors from this list.- Specified by:
clearRequestInterceptorsin interfaceHttpRequestInterceptorList
-
addResponseInterceptor
Description copied from interface:HttpResponseInterceptorListAppends a response interceptor to this list.- Specified by:
addResponseInterceptorin interfaceHttpResponseInterceptorList- Parameters:
itcp- the response interceptor to add
-
addInterceptor
Same asaddResponseInterceptor.- Parameters:
interceptor- the interceptor to add
-
addInterceptor
-
getResponseInterceptorCount
public int getResponseInterceptorCount()Description copied from interface:HttpResponseInterceptorListObtains the current size of this list.- Specified by:
getResponseInterceptorCountin interfaceHttpResponseInterceptorList- Returns:
- the number of response interceptors in this list
-
getResponseInterceptor
Description copied from interface:HttpResponseInterceptorListObtains a response interceptor from this list.- Specified by:
getResponseInterceptorin interfaceHttpResponseInterceptorList- Parameters:
index- the index of the interceptor to obtain, 0 for first- Returns:
- the interceptor at the given index, or
nullif the index is out of range
-
clearResponseInterceptors
public void clearResponseInterceptors()Description copied from interface:HttpResponseInterceptorListRemoves all response interceptors from this list.- Specified by:
clearResponseInterceptorsin interfaceHttpResponseInterceptorList
-
setInterceptors
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.- Specified by:
setInterceptorsin interfaceHttpRequestInterceptorList- Specified by:
setInterceptorsin interfaceHttpResponseInterceptorList- Parameters:
list- the list of request and response interceptors from which to initialize
-
clearInterceptors
public void clearInterceptors()Clears both interceptor lists maintained by this processor. -
process
Description copied from interface:HttpRequestInterceptorProcesses 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.- Specified by:
processin interfaceHttpRequestInterceptor- Parameters:
request- the request to preprocesscontext- the context for the request- Throws:
IOException- in case of an IO problemHttpException- in case of a protocol or other problem
-
process
Description copied from interface:HttpResponseInterceptorProcesses 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.- Specified by:
processin interfaceHttpResponseInterceptor- Parameters:
response- the response to postprocesscontext- the context for the request- Throws:
IOException- in case of an IO problemHttpException- in case of a protocol or other problem
-
copyInterceptors
-
copy
Creates a copy of this instance- Returns:
- new instance of the BasicHttpProcessor
-
clone
Description copied from class:ObjectCreates and returns a copy of thisObject. The default implementation returns a so-called "shallow" copy: It creates a new instance of the same class and then copies the field values (including object references) from this instance to the new instance. A "deep" copy, in contrast, would also recursively clone nested objects. A subclass that needs to implement this kind of cloning should callsuper.clone()to create the new instance and then create deep copies of the nested, mutable objects.- Overrides:
clonein classObject- Returns:
- a copy of this object.
- Throws:
CloneNotSupportedException- if this object's class does not implement theCloneableinterface.
-