Package net.jadler

Class Request.Builder

  • Enclosing class:
    Request

    public static class Request.Builder
    extends Object
    A builder class for Request instances.
    • Method Detail

      • method

        public Request.Builder method​(String method)
        Sets the request method. Must be called before build().
        Parameters:
        method - request method
        Returns:
        this builder
      • requestURI

        public Request.Builder requestURI​(URI requestURI)
        Sets the request URI. Must be called before build().
        Parameters:
        requestURI - request URI
        Returns:
        this builder
      • body

        public Request.Builder body​(byte[] body)
        Sets the request body. If not called, an empty body will be used.
        Parameters:
        body - request body (cannot be null)
        Returns:
        this builder
      • headers

        public Request.Builder headers​(KeyValues headers)
        Sets the request headers (all previously defined headers will be lost).
        Parameters:
        headers - request headers (cannot be null)
        Returns:
        this builder
      • header

        public Request.Builder header​(String name,
                                      String value)
        Adds a request header to the constructed request instance.
        Parameters:
        name - header name (cannot be empty)
        value - header value (cannot be null)
        Returns:
        this builder
      • encoding

        public Request.Builder encoding​(Charset encoding)
        Sets the request encoding. If not set null value will be used signalizing no encoding was set in the incoming request (using the Content-Type header)
        Parameters:
        encoding - request encoding (can be null)
        Returns:
        this builder