Class HttpRequest<T>

java.lang.Object
aQute.bnd.http.HttpRequest<T>
Type Parameters:
T -

public class HttpRequest<T> extends Object
Builds up a request
  • Field Details

    • verb

      String verb
    • isIdemPotent

      boolean isIdemPotent
    • upload

      Object upload
    • download

      Type download
    • headers

      Map<String,String> 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

  • Method Details

    • get

      public <X> HttpRequest<X> get(Class<X> type)
      Convert the result to a specific type
    • get

      public <X> HttpRequest<X> get(TypeReference<X> type)
      Convert the result to a specific type
    • get

      public HttpRequest<Object> get(Type type)
      Convert the result to a specific type
    • verb

      public HttpRequest<T> verb(String 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

      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
    • trace

      public HttpRequest<T> trace()
      Set the verb/method to option
    • delete

      public HttpRequest<T> delete()
      Set the verb/method to delete
    • upload

      public HttpRequest<T> upload(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(Map<String,String> map)
      Add headers to request
    • headers

      public HttpRequest<T> headers(String key, String value)
      Add header to request
    • timeout

      public HttpRequest<T> timeout(long timeoutInMs)
      Set timeout in ms
    • ifNoneMatch

      public HttpRequest<T> ifNoneMatch(String etag)
    • ifModifiedSince

      public HttpRequest<T> ifModifiedSince(long epochTime)
    • maxRedirects

      public HttpRequest<T> maxRedirects(int n)
    • go

      public T go(URL url) throws Exception
      Throws:
      Exception
    • go

      public T go(URI url) throws Exception
      Throws:
      Exception
    • age

      public HttpRequest<T> age(int n, TimeUnit tu)
    • async

      public org.osgi.util.promise.Promise<T> async(URL url)
    • async

      public org.osgi.util.promise.Promise<T> async(URI uri)
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • ifUnmodifiedSince

      public HttpRequest<T> ifUnmodifiedSince(long ifNotModifiedSince)
    • ifMatch

      public HttpRequest<T> ifMatch(String etag)
    • asTag

      public HttpRequest<TaggedData> asTag()
    • asString

      public HttpRequest<String> asString()
    • isCache

      public boolean isCache()
    • useCache

      public HttpRequest<File> useCache(long maxStale)
    • useCache

      public HttpRequest<File> useCache()
    • useCache

      public HttpRequest<File> useCache(File file)
    • useCache

      public HttpRequest<File> useCache(File file, long maxStale)
    • report

      public HttpRequest<T> report(Reporter reporter)
    • timeout

      public HttpRequest<T> timeout(long timeout, TimeUnit unit)
    • isTagResult

      public boolean isTagResult()
    • updateTag

      public HttpRequest<T> updateTag()
    • retries

      public HttpRequest<T> retries(int retries)
      Set the number of retries. Retries are only attempted when the method verb implies idempotency, or it is explicitly set to be idempotent, see idemPotent(boolean).
      Parameters:
      retries - number of retries, default is 3.
      Returns:
      this
    • retryDelay

      public HttpRequest<T> retryDelay(int retryDelay)
    • idemPotent

      public HttpRequest<T> idemPotent(boolean isIdemPotent)
      Idempotent Methods

      Methods 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