Class HttpRequest<T>

  • Type Parameters:
    T -

    public class HttpRequest<T>
    extends java.lang.Object
    Builds up a request
    • 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 class java.lang.Object
      • ifUnmodifiedSince

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

        public HttpRequest<T> ifMatch​(java.lang.String etag)
      • 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()