Package aQute.bnd.http
Class HttpRequest<T>
java.lang.Object
aQute.bnd.http.HttpRequest<T>
- Type Parameters:
T
-
Builds up a request
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) boolean
(package private) HttpClient
(package private) Type
(package private) String
(package private) long
(package private) String
(package private) long
(package private) boolean
(package private) long
(package private) int
(package private) Reporter
(package private) int
(package private) long
(package private) long
(package private) boolean
(package private) Object
(package private) URL
(package private) File
(package private) String
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionasString()
asTag()
org.osgi.util.promise.Promise<T>
org.osgi.util.promise.Promise<T>
delete()
Set the verb/method to deleteget()
Set the verb/method to get<X> HttpRequest<X>
get
(TypeReference<X> type) Convert the result to a specific type<X> HttpRequest<X>
Convert the result to a specific typeConvert the result to a specific typehead()
Set the verb/method to headAdd header to requestAdd headers to requestidemPotent
(boolean isIdemPotent) Idempotent MethodsifModifiedSince
(long epochTime) ifNoneMatch
(String etag) ifUnmodifiedSince
(long ifNotModifiedSince) boolean
isCache()
boolean
maxRedirects
(int n) option()
Set the verb/method to optionpost()
Set the verb/method to postput()
Set the verb/method to putretries
(int retries) Set the number of retries.retryDelay
(int retryDelay) timeout
(long timeoutInMs) Set timeout in mstoString()
trace()
Set the verb/method to optionSet the object to upload.useCache()
useCache
(long maxStale) Set the HTTP verb.
-
Field Details
-
verb
String verb -
isIdemPotent
boolean isIdemPotent -
upload
Object upload -
download
Type download -
headers
-
timeout
long timeout -
client
HttpClient client -
ifNoneMatch
String ifNoneMatch -
ifModifiedSince
long ifModifiedSince -
ifUnmodifiedSince
long ifUnmodifiedSince -
url
URL url -
redirects
int redirects -
ifMatch
String ifMatch -
cached
boolean cached -
maxStale
long maxStale -
reporter
Reporter reporter -
useCacheFile
File useCacheFile -
updateTag
boolean updateTag -
retries
int retries -
retryDelay
long retryDelay
-
-
Constructor Details
-
HttpRequest
HttpRequest(HttpClient client)
-
-
Method Details
-
get
Convert the result to a specific type -
get
Convert the result to a specific type -
get
Convert the result to a specific type -
verb
Set the HTTP verb. The methods GET, HEAD, PUT and DELETE are idempotent. Also, the methods OPTIONS and TRACE SHOULD NOT have side effects, and so are inherently idempotent. -
put
Set the verb/method to put -
head
Set the verb/method to head -
get
Set the verb/method to get -
post
Set the verb/method to post -
option
Set the verb/method to option -
trace
Set the verb/method to option -
delete
Set the verb/method to delete -
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
Add headers to request -
headers
Add header to request -
timeout
Set timeout in ms -
ifNoneMatch
-
ifModifiedSince
-
maxRedirects
-
go
- Throws:
Exception
-
go
- Throws:
Exception
-
age
-
async
-
async
-
toString
-
ifUnmodifiedSince
-
ifMatch
-
asTag
-
asString
-
isCache
public boolean isCache() -
useCache
-
useCache
-
useCache
-
useCache
-
report
-
timeout
-
isTagResult
public boolean isTagResult() -
updateTag
-
retries
Set the number of retries. Retries are only attempted when the method verb implies idempotency, or it is explicitly set to be idempotent, seeidemPotent(boolean)
.- Parameters:
retries
- number of retries, default is 3.- Returns:
- this
-
retryDelay
-
idemPotent
Idempotent MethodsMethods can also have the property of "idempotence" in that (aside from error or expiration issues) the side-effects of N > 0 identical requests is the same as for a single request. The methods GET, HEAD, PUT and DELETE share this property. Also, the methods OPTIONS and TRACE SHOULD NOT have side effects, and so are inherently idempotent.
The
verb(String)
method will set the idempotency according to this specification. This method can then override the default idempotency.- Parameters:
isIdemPotent
- if the to be used method is idempotent. (Is overridden if the method verb is set after this method!)- Returns:
- this
-