|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.lucene.replicator.http.HttpClientBase
public abstract class HttpClientBase
Base class for Http clients.
Field Summary | |
---|---|
static int |
DEFAULT_CONNECTION_TIMEOUT
Default connection timeout for this client, in milliseconds. |
static int |
DEFAULT_SO_TIMEOUT
Default socket timeout for this client, in milliseconds. |
protected String |
url
The URL stting to execute requests against. |
Constructor Summary | |
---|---|
protected |
HttpClientBase(String host,
int port,
String path,
org.apache.http.conn.ClientConnectionManager conMgr)
|
Method Summary | ||
---|---|---|
void |
close()
|
|
protected
|
doAction(org.apache.http.HttpResponse response,
boolean consume,
Callable<T> call)
Do a specific action and validate after the action that the status is still OK, and if not, attempt to extract the actual server side exception. |
|
protected
|
doAction(org.apache.http.HttpResponse response,
Callable<T> call)
Same as doAction(HttpResponse, boolean, Callable) but always do consume at the end. |
|
protected void |
ensureOpen()
Throws AlreadyClosedException if this client is already closed. |
|
protected org.apache.http.HttpResponse |
executeGET(String request,
String... params)
internal: execute a request and return its result The params argument is treated as: name1,value1,name2,value2,... |
|
protected org.apache.http.HttpResponse |
executePOST(String request,
org.apache.http.HttpEntity entity,
String... params)
internal: execute a request and return its result The params argument is treated as: name1,value1,name2,value2,... |
|
protected boolean |
isClosed()
Returns true iff this instance was closed , otherwise
returns false. |
|
InputStream |
responseInputStream(org.apache.http.HttpResponse response)
Internal utility: input stream of the provided response |
|
InputStream |
responseInputStream(org.apache.http.HttpResponse response,
boolean consume)
Internal utility: input stream of the provided response, which optionally consumes the response's resources when the input stream is exhausted. |
|
void |
setConnectionTimeout(int timeout)
Set the connection timeout for this client, in milliseconds. |
|
void |
setSoTimeout(int timeout)
Set the socket timeout for this client, in milliseconds. |
|
protected void |
throwKnownError(org.apache.http.HttpResponse response,
org.apache.http.StatusLine statusLine)
|
|
protected void |
verifyStatus(org.apache.http.HttpResponse response)
Internal: response status after invocation, and in case or error attempt to read the exception sent by the server. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int DEFAULT_CONNECTION_TIMEOUT
setConnectionTimeout(int)
,
Constant Field Valuespublic static final int DEFAULT_SO_TIMEOUT
setSoTimeout(int)
,
Constant Field Valuesprotected final String url
Constructor Detail |
---|
protected HttpClientBase(String host, int port, String path, org.apache.http.conn.ClientConnectionManager conMgr)
conMgr
- connection manager to use for this http client.
NOTE:The provided ClientConnectionManager
will not be
ClientConnectionManager.shutdown()
by this class.Method Detail |
---|
public void setConnectionTimeout(int timeout)
HttpConnectionParams.setConnectionTimeout(org.apache.http.params.HttpParams, int)
.
timeout
- timeout to set, in millisecopndspublic void setSoTimeout(int timeout)
HttpConnectionParams.setSoTimeout(org.apache.http.params.HttpParams, int)
.
timeout
- timeout to set, in millisecopndsprotected final void ensureOpen() throws AlreadyClosedException
AlreadyClosedException
if this client is already closed.
AlreadyClosedException
protected void verifyStatus(org.apache.http.HttpResponse response) throws IOException
IOException
protected void throwKnownError(org.apache.http.HttpResponse response, org.apache.http.StatusLine statusLine) throws IOException
IOException
protected org.apache.http.HttpResponse executePOST(String request, org.apache.http.HttpEntity entity, String... params) throws IOException
params
argument is treated as: name1,value1,name2,value2,...
IOException
protected org.apache.http.HttpResponse executeGET(String request, String... params) throws IOException
params
argument is treated as: name1,value1,name2,value2,...
IOException
public InputStream responseInputStream(org.apache.http.HttpResponse response) throws IOException
IOException
public InputStream responseInputStream(org.apache.http.HttpResponse response, boolean consume) throws IOException
IOException
protected final boolean isClosed()
closed
, otherwise
returns false. Note that if you override close()
, you must call
super.close()
, in order for this instance to be properly closed.
protected <T> T doAction(org.apache.http.HttpResponse response, Callable<T> call) throws IOException
doAction(HttpResponse, boolean, Callable)
but always do consume at the end.
IOException
protected <T> T doAction(org.apache.http.HttpResponse response, boolean consume, Callable<T> call) throws IOException
consume
parameter.
IOException
public void close() throws IOException
close
in interface Closeable
IOException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |