Class HttpRequestHttpURLConnectionAdapter

  • All Implemented Interfaces:
    HttpRequest

    public class HttpRequestHttpURLConnectionAdapter
    extends java.lang.Object
    implements HttpRequest
    Class implementing the HttpRequest and forwarding calls to HttpURLConnection adaptee.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String getHeader​(java.lang.String name)
      Gets the header's value.
      java.util.Map<java.lang.String,​java.util.List<java.lang.String>> getHeaders()
      Gets an immutable map containing the request headers and their values.
      java.lang.String getMethod()
      Gets the HTTP request method.
      java.net.URL getUrl()
      Gets the HTTP request URL.
      void setHeader​(java.lang.String name, java.lang.String value)
      Sets an HTTP header or overwrites an existing HTTP header with new value.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • HttpRequestHttpURLConnectionAdapter

        public HttpRequestHttpURLConnectionAdapter​(java.net.HttpURLConnection httpURLConnection)
        Initializes a new instance of HttpRequestHttpURLConnectionAdapter
        Parameters:
        httpURLConnection - underlying HttpURLConnection
    • Method Detail

      • getUrl

        public java.net.URL getUrl()
        Description copied from interface: HttpRequest
        Gets the HTTP request URL.
        Specified by:
        getUrl in interface HttpRequest
      • getMethod

        public java.lang.String getMethod()
        Description copied from interface: HttpRequest
        Gets the HTTP request method.
        Specified by:
        getMethod in interface HttpRequest
      • getHeaders

        public java.util.Map<java.lang.String,​java.util.List<java.lang.String>> getHeaders()
        Description copied from interface: HttpRequest
        Gets an immutable map containing the request headers and their values.
        Specified by:
        getHeaders in interface HttpRequest
      • getHeader

        public java.lang.String getHeader​(java.lang.String name)
        Description copied from interface: HttpRequest
        Gets the header's value.
        Specified by:
        getHeader in interface HttpRequest
        Parameters:
        name - Header name for which to retrieve the value.
        Returns:
        The header's value, which might also be null if not set.
      • setHeader

        public void setHeader​(java.lang.String name,
                              java.lang.String value)
        Description copied from interface: HttpRequest
        Sets an HTTP header or overwrites an existing HTTP header with new value.

        Trying to set an HTTP header with null name will return immediately. Trying to set one of the following restricted headers will also return immediately.

        • Access-Control-Request-Headers
        • Access-Control-Request-Method
        • Connection
        • Content-Length
        • Content-Transfer-Encoding
        • Host
        • Keep-Alive
        • Origin
        • Trailer
        • Transfer-Encoding
        • Upgrade
        • Via
        Specified by:
        setHeader in interface HttpRequest
        Parameters:
        name - The header's name, which must not be null or any of the restricted headers.
        value - The header's value