Package net.jadler

Class Request


  • public class Request
    extends Object

    Immutable http request abstraction. Provides request method, URI, body, parameters and headers.

    To create instances of this class use builder().

    • Method Detail

      • getMethod

        public String getMethod()
        Returns:
        http method
      • getURI

        public URI getURI()
        Returns:
        URI of the request. For example http://localhost:8080/test/file?a=4
      • getParameters

        public KeyValues getParameters()
        Returns:
        all http parameters (read from both query string and request body) from this request. Never returns null
      • getHeaders

        public KeyValues getHeaders()
        Returns:
        all http headers from this request. Never returns null
      • getBodyAsStream

        public InputStream getBodyAsStream()
        Returns the body content as an InputStream instance. This method can be called multiple times always returning valid, readable stream.
        Returns:
        request body as an InputStream instance
      • getBodyAsBytes

        public byte[] getBodyAsBytes()
        Returns:
        request body as an array of bytes
      • getBodyAsString

        public String getBodyAsString()
        Returns:
        request body as a string (if the body is empty, returns an empty string). If no encoding was set using the Content-Type header ISO-8859-1 will be used (http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html).
      • getContentType

        public String getContentType()
        Returns:
        value of the Content-Type header.
      • getEncoding

        public Charset getEncoding()
        Returns:
        request body encoding set by the Content-Type header or null if not set