Package aQute.bnd.http
Class HttpRequest<T>
- java.lang.Object
-
- aQute.bnd.http.HttpRequest<T>
-
- Type Parameters:
T
-
public class HttpRequest<T> extends java.lang.Object
Builds up a request
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description HttpRequest<T>
age(int n, java.util.concurrent.TimeUnit tu)
HttpRequest<java.lang.String>
asString()
HttpRequest<TaggedData>
asTag()
org.osgi.util.promise.Promise<T>
async(java.net.URI uri)
org.osgi.util.promise.Promise<T>
async(java.net.URL url)
HttpRequest<T>
delete()
Set the verb/method to deleteHttpRequest<T>
get()
Set the verb/method to get<X> HttpRequest<X>
get(aQute.lib.converter.TypeReference<X> type)
Convert the result to a specific type<X> HttpRequest<X>
get(java.lang.Class<X> type)
Convert the result to a specific typeHttpRequest<java.lang.Object>
get(java.lang.reflect.Type type)
Convert the result to a specific typeT
go(java.net.URI url)
T
go(java.net.URL url)
HttpRequest<T>
head()
Set the verb/method to headHttpRequest<T>
headers(java.lang.String key, java.lang.String value)
Add header to requestHttpRequest<T>
headers(java.util.Map<java.lang.String,java.lang.String> map)
Add headers to requestHttpRequest<T>
ifMatch(java.lang.String etag)
HttpRequest<T>
ifModifiedSince(long epochTime)
HttpRequest<T>
ifNoneMatch(java.lang.String etag)
HttpRequest<T>
ifUnmodifiedSince(long ifNotModifiedSince)
boolean
isCache()
boolean
isTagResult()
HttpRequest<T>
maxRedirects(int n)
HttpRequest<T>
option()
Set the verb/method to optionHttpRequest<T>
post()
Set the verb/method to postHttpRequest<T>
put()
Set the verb/method to putHttpRequest<T>
report(aQute.service.reporter.Reporter reporter)
HttpRequest<T>
timeout(long timeoutInMs)
Set timeout in msHttpRequest<T>
timeout(long timeout, java.util.concurrent.TimeUnit unit)
java.lang.String
toString()
HttpRequest<T>
updateTag()
HttpRequest<T>
upload(java.lang.Object upload)
Set the object to upload.HttpRequest<java.io.File>
useCache()
HttpRequest<java.io.File>
useCache(long maxStale)
HttpRequest<java.io.File>
useCache(java.io.File file)
HttpRequest<java.io.File>
useCache(java.io.File file, long maxStale)
HttpRequest<T>
verb(java.lang.String verb)
Set the HTTP verb
-
-
-
Method Detail
-
get
public <X> HttpRequest<X> get(java.lang.Class<X> type)
Convert the result to a specific type
-
get
public <X> HttpRequest<X> get(aQute.lib.converter.TypeReference<X> type)
Convert the result to a specific type
-
get
public HttpRequest<java.lang.Object> get(java.lang.reflect.Type type)
Convert the result to a specific type
-
verb
public HttpRequest<T> verb(java.lang.String verb)
Set the HTTP verb
-
put
public HttpRequest<T> put()
Set the verb/method to put
-
head
public HttpRequest<T> head()
Set the verb/method to head
-
get
public HttpRequest<T> get()
Set the verb/method to get
-
post
public HttpRequest<T> post()
Set the verb/method to post
-
option
public HttpRequest<T> option()
Set the verb/method to option
-
delete
public HttpRequest<T> delete()
Set the verb/method to delete
-
upload
public HttpRequest<T> upload(java.lang.Object upload)
Set the object to upload. Can be of several types:- InputStream – copied verbatim
- String – content sent
- byte[] – content sent
- File – content sent
- Otherwise assumes DTO and encodes in JSON
-
headers
public HttpRequest<T> headers(java.util.Map<java.lang.String,java.lang.String> map)
Add headers to request
-
headers
public HttpRequest<T> headers(java.lang.String key, java.lang.String value)
Add header to request
-
timeout
public HttpRequest<T> timeout(long timeoutInMs)
Set timeout in ms
-
ifNoneMatch
public HttpRequest<T> ifNoneMatch(java.lang.String etag)
-
ifModifiedSince
public HttpRequest<T> ifModifiedSince(long epochTime)
-
maxRedirects
public HttpRequest<T> maxRedirects(int n)
-
go
public T go(java.net.URL url) throws java.lang.Exception
- Throws:
java.lang.Exception
-
go
public T go(java.net.URI url) throws java.lang.Exception
- Throws:
java.lang.Exception
-
age
public HttpRequest<T> age(int n, java.util.concurrent.TimeUnit tu)
-
async
public org.osgi.util.promise.Promise<T> async(java.net.URL url) throws java.lang.InterruptedException
- Throws:
java.lang.InterruptedException
-
async
public org.osgi.util.promise.Promise<T> async(java.net.URI uri) throws java.net.MalformedURLException, java.lang.InterruptedException
- Throws:
java.net.MalformedURLException
java.lang.InterruptedException
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
ifUnmodifiedSince
public HttpRequest<T> ifUnmodifiedSince(long ifNotModifiedSince)
-
ifMatch
public HttpRequest<T> ifMatch(java.lang.String etag)
-
asTag
public HttpRequest<TaggedData> asTag()
-
asString
public HttpRequest<java.lang.String> asString()
-
isCache
public boolean isCache()
-
useCache
public HttpRequest<java.io.File> useCache(long maxStale)
-
useCache
public HttpRequest<java.io.File> useCache()
-
useCache
public HttpRequest<java.io.File> useCache(java.io.File file)
-
useCache
public HttpRequest<java.io.File> useCache(java.io.File file, long maxStale)
-
report
public HttpRequest<T> report(aQute.service.reporter.Reporter reporter)
-
timeout
public HttpRequest<T> timeout(long timeout, java.util.concurrent.TimeUnit unit)
-
isTagResult
public boolean isTagResult()
-
updateTag
public HttpRequest<T> updateTag()
-
-