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 TypeFieldDescription(package private) final Map<URLConnectionHandler,
Semaphore> private URLCache
(package private) static final JSONCodec
private final List<URLConnectionHandler>
private ConnectionSettings
(package private) static final long
private boolean
(package private) static final long
(package private) static final org.slf4j.Logger
(package private) static final long
private AtomicBoolean
private ThreadLocal<PasswordAuthentication>
private final org.osgi.util.promise.PromiseFactory
private final List<ProxyHandler>
private Registry
private Reporter
(package private) int
(package private) long
static final SimpleDateFormat
Deprecated. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addProxyHandler
(ProxyHandler proxyHandler) void
build()
cache()
void
close()
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 benull
if the remote resource is unchanged.<T> T
connectWithProxy
(ProxyHandler.ProxySetup proxySetup, Callable<T> r) (package private) InputStream
createProgressWrappedStream
(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) void
init()
boolean
org.osgi.util.promise.PromiseFactory
void
readSettings
(Processor processor) void
reportSettings
(Formatter out) retries
(int retries) retryDelay
(int retryDelay) <T> T
send
(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) void
void
void
setOffline
(AtomicBoolean offline) void
setRegistry
(Registry registry) void
setReporter
(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 -
blocker
-
-
Constructor Details
-
HttpClient
public HttpClient()
-
-
Method Details
-
init
void init() -
close
public void close()- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
-
connect
Description copied from interface:URLConnector
Connect to the specified URL.- Specified by:
connect
in interfaceURLConnector
- Throws:
IOException
Exception
-
connectTagged
Description copied from interface:URLConnector
Connect to the specified URL, also returning the ETag if available.- Specified by:
connectTagged
in interfaceURLConnector
- Parameters:
url
- The remote URL.- Returns:
- An instance of
TaggedData
; note that theTaggedData.getTag()
method may returnnull
if the resource has no tag. - Throws:
IOException
- @since 1.1Exception
-
connectTagged
Description copied from interface:URLConnector
Connect to the specified URL while providing the last known tag for the remote resource; the response will benull
if the remote resource is unchanged.- Specified by:
connectTagged
in interfaceURLConnector
- Parameters:
url
- The remote URL.tag
- The last known tag value for the resource.- Returns:
- An instance of
TaggedData
, ornull
if 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:
MalformedURLException
Exception
-
toName
- Throws:
Exception
-
getCacheFileFor
- Throws:
Exception
-
readSettings
- Throws:
IOException
Exception
-
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
-