Class CommonsHTTPSender.BackgroundHTTPThread
- java.lang.Object
-
- java.lang.Thread
-
- org.apache.manifoldcf.connectorcommon.common.CommonsHTTPSender.BackgroundHTTPThread
-
- All Implemented Interfaces:
java.lang.Runnable
- Enclosing class:
- CommonsHTTPSender
protected static class CommonsHTTPSender.BackgroundHTTPThread extends java.lang.Thread
This thread does the actual socket communication with the server. It's set up so that it can be abandoned at shutdown time. The way it works is as follows: - it starts the transaction - it receives the response, and saves that for the calling class to inspect - it transfers the data part to an input stream provided to the calling class - it shuts the connection down If there is an error, the sequence is aborted, and an exception is recorded for the calling class to examine. The calling class basically accepts the sequence above. It starts the thread, and tries to get a response code. If instead an exception is seen, the exception is thrown up the stack.
-
-
Field Summary
Fields Modifier and Type Field Description protected boolean
abortThread
protected java.io.InputStream
bodyStream
protected java.nio.charset.Charset
charSet
protected org.apache.http.client.methods.HttpRequestBase
executeMethod
protected java.lang.Throwable
generalException
protected org.apache.http.client.HttpClient
httpClient
Client and method, all preconfiguredprotected org.apache.http.HttpResponse
response
protected java.lang.Throwable
responseException
protected java.lang.Throwable
shutdownException
protected boolean
streamCreated
protected java.lang.Throwable
streamException
protected XThreadInputStream
threadStream
-
Constructor Summary
Constructors Constructor Description BackgroundHTTPThread(org.apache.http.client.HttpClient httpClient, org.apache.http.client.methods.HttpRequestBase executeMethod)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
abort()
protected void
checkException(java.lang.Throwable exception)
void
finishUp()
java.nio.charset.Charset
getCharSet()
java.lang.String
getFirstHeader(java.lang.String headerName)
int
getResponseCode()
java.util.Map<java.lang.String,java.util.List<java.lang.String>>
getResponseHeaders()
java.lang.String
getResponseStatus()
java.io.InputStream
getSafeInputStream()
void
run()
-
Methods inherited from class java.lang.Thread
activeCount, checkAccess, clone, countStackFrames, currentThread, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, onSpinWait, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, suspend, toString, yield
-
-
-
-
Field Detail
-
httpClient
protected final org.apache.http.client.HttpClient httpClient
Client and method, all preconfigured
-
executeMethod
protected final org.apache.http.client.methods.HttpRequestBase executeMethod
-
response
protected org.apache.http.HttpResponse response
-
responseException
protected java.lang.Throwable responseException
-
threadStream
protected XThreadInputStream threadStream
-
bodyStream
protected java.io.InputStream bodyStream
-
charSet
protected java.nio.charset.Charset charSet
-
streamCreated
protected boolean streamCreated
-
streamException
protected java.lang.Throwable streamException
-
abortThread
protected boolean abortThread
-
shutdownException
protected java.lang.Throwable shutdownException
-
generalException
protected java.lang.Throwable generalException
-
-
Method Detail
-
run
public void run()
- Specified by:
run
in interfacejava.lang.Runnable
- Overrides:
run
in classjava.lang.Thread
-
getResponseCode
public int getResponseCode() throws java.lang.InterruptedException, java.io.IOException, org.apache.http.HttpException
- Throws:
java.lang.InterruptedException
java.io.IOException
org.apache.http.HttpException
-
getResponseStatus
public java.lang.String getResponseStatus() throws java.lang.InterruptedException, java.io.IOException, org.apache.http.HttpException
- Throws:
java.lang.InterruptedException
java.io.IOException
org.apache.http.HttpException
-
getResponseHeaders
public java.util.Map<java.lang.String,java.util.List<java.lang.String>> getResponseHeaders() throws java.lang.InterruptedException, java.io.IOException, org.apache.http.HttpException
- Throws:
java.lang.InterruptedException
java.io.IOException
org.apache.http.HttpException
-
getFirstHeader
public java.lang.String getFirstHeader(java.lang.String headerName) throws java.lang.InterruptedException, java.io.IOException, org.apache.http.HttpException
- Throws:
java.lang.InterruptedException
java.io.IOException
org.apache.http.HttpException
-
getSafeInputStream
public java.io.InputStream getSafeInputStream() throws java.lang.InterruptedException, java.io.IOException, org.apache.http.HttpException
- Throws:
java.lang.InterruptedException
java.io.IOException
org.apache.http.HttpException
-
getCharSet
public java.nio.charset.Charset getCharSet() throws java.lang.InterruptedException, java.io.IOException, org.apache.http.HttpException
- Throws:
java.lang.InterruptedException
java.io.IOException
org.apache.http.HttpException
-
abort
public void abort()
-
finishUp
public void finishUp() throws java.lang.InterruptedException
- Throws:
java.lang.InterruptedException
-
checkException
protected void checkException(java.lang.Throwable exception) throws java.io.IOException, org.apache.http.HttpException
- Throws:
java.io.IOException
org.apache.http.HttpException
-
-