Package aQute.bnd.http
Class HttpClient
java.lang.Object
aQute.bnd.http.HttpClient
- All Implemented Interfaces:
URLConnector,Closeable,AutoCloseable
A simple Http Client that inter-works with the bnd registry. It provides an
easy way to construct a URL request. The request is then decorated with third
parties that are in the bnd registry for proxies and authentication models.
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate URLCache(package private) static final JSONCodecprivate final List<URLConnectionHandler>private ConnectionSettings(package private) static final longprivate boolean(package private) static final long(package private) static final org.slf4j.Logger(package private) static final longprivate AtomicBooleanprivate ThreadLocal<PasswordAuthentication>private final org.osgi.util.promise.PromiseFactoryprivate final List<ProxyHandler>private Registryprivate Reporter(package private) int(package private) longstatic final SimpleDateFormatDeprecated. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddProxyHandler(ProxyHandler proxyHandler) voidbuild()cache()voidclose()Connect to the specified URL.connectTagged(URL url) Connect to the specified URL, also returning the ETag if available.connectTagged(URL url, String tag) Connect to the specified URL while providing the last known tag for the remote resource; the response will benullif the remote resource is unchanged.<T> TconnectWithProxy(ProxyHandler.ProxySetup proxySetup, Callable<T> r) (package private) InputStreamcreateProgressWrappedStream(InputStream inputStream, String name, int size, ProgressPlugin.Task task, long timeout) findMatchingHandler(URL url) getCacheFileFor(URI url) private Collection<? extends ProxyHandler>getProxySetup(URL url) private Collection<? extends URLConnectionHandler>getUserFor(String base) (package private) voidinit()booleanorg.osgi.util.promise.PromiseFactoryvoidreadSettings(Processor processor) voidreportSettings(Formatter out) retries(int retries) retryDelay(int retryDelay) <T> Tsend(HttpRequest<T> request) send0(HttpRequest<?> request) (package private) <T> org.osgi.util.promise.Promise<T>sendAsync(HttpRequest<T> request) private <T> org.osgi.util.promise.Promise<T>sendAsync(HttpRequest<T> request, int retries, long delay) voidvoidvoidsetOffline(AtomicBoolean offline) voidsetRegistry(Registry registry) voidsetReporter(Reporter reporter) validateURI(URI u) Validate a URI to see if it is supported by this client
-
Field Details
-
logger
static final org.slf4j.Logger logger -
sdf
Deprecated. -
INITIAL_TIMEOUT
static final long INITIAL_TIMEOUT -
FINAL_TIMEOUT
static final long FINAL_TIMEOUT -
MAX_RETRY_DELAY
static final long MAX_RETRY_DELAY -
proxyHandlers
-
connectionHandlers
-
passwordAuthentication
-
inited
private boolean inited -
codec
-
cache
-
registry
-
reporter
-
offline
-
promiseFactory
private final org.osgi.util.promise.PromiseFactory promiseFactory -
connectionSettings
-
retries
int retries -
retryDelay
long retryDelay
-
-
Constructor Details
-
HttpClient
public HttpClient()
-
-
Method Details
-
init
void init() -
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-
connect
Description copied from interface:URLConnectorConnect to the specified URL.- Specified by:
connectin interfaceURLConnector- Throws:
IOExceptionException
-
connectTagged
Description copied from interface:URLConnectorConnect to the specified URL, also returning the ETag if available.- Specified by:
connectTaggedin interfaceURLConnector- Parameters:
url- The remote URL.- Returns:
- An instance of
TaggedData; note that theTaggedData.getTag()method may returnnullif the resource has no tag. - Throws:
IOException- @since 1.1Exception
-
connectTagged
Description copied from interface:URLConnectorConnect to the specified URL while providing the last known tag for the remote resource; the response will benullif the remote resource is unchanged.- Specified by:
connectTaggedin interfaceURLConnector- Parameters:
url- The remote URL.tag- The last known tag value for the resource.- Returns:
- An instance of
TaggedData, ornullif the resource has not modified (i.e., if it has the same tag value). - Throws:
IOException- @since 1.1Exception
-
build
-
sendAsync
-
sendAsync
private <T> org.osgi.util.promise.Promise<T> sendAsync(HttpRequest<T> request, int retries, long delay) -
send
- Throws:
Exception
-
send0
- Throws:
Exception
-
getProxySetup
- Throws:
Exception
-
connectWithProxy
- Throws:
Exception
-
findMatchingHandler
-
getURLConnectionHandlers
-
getProxyHandlers
- Throws:
Exception
-
createProgressWrappedStream
InputStream createProgressWrappedStream(InputStream inputStream, String name, int size, ProgressPlugin.Task task, long timeout) -
setCache
-
setReporter
-
setRegistry
-
addURLConnectionHandler
-
getReporter
-
addProxyHandler
-
setLog
- Throws:
IOException
-
getUserFor
- Throws:
MalformedURLExceptionException
-
toName
- Throws:
Exception
-
getCacheFileFor
- Throws:
Exception
-
readSettings
- Throws:
IOExceptionException
-
makeDir
- Throws:
URISyntaxException
-
isOffline
public boolean isOffline() -
setOffline
-
promiseFactory
public org.osgi.util.promise.PromiseFactory promiseFactory() -
cache
-
reportSettings
-
retries
-
retryDelay
-
validateURI
Validate a URI to see if it is supported by this client- Parameters:
u- the uri- Returns:
- null if ok, otherwise a reason why it is invalid
-