Class HttpRequest.Builder

    • Constructor Detail

      • Builder

        public Builder()
        Constructs a new builder for an HTTP request.
    • Method Detail

      • withUrl

        public HttpRequest.Builder withUrl​(String url)
        Sets the URL that the request will be performed against.
        Parameters:
        url - the URL that the request will be performed against.
        Returns:
        the builder.
      • withMethod

        public HttpRequest.Builder withMethod​(HttpMethod method)
        Sets the HTTP method of the request.
        Parameters:
        method - the HTTP method of the request.
        Returns:
        the builder.
      • withAuthUrl

        public HttpRequest.Builder withAuthUrl​(String authUrl)
        Sets the URL that will be used to capture cookies for authentication before the actual request is executed.
        Parameters:
        authUrl - the URL that will be used to capture cookies for authentication before the actual request is executed.
        Returns:
        the builder.
      • withHeaders

        public HttpRequest.Builder withHeaders​(Map<String,​Collection<String>> headers)
        Sets the headers that will be included in the request.
        Parameters:
        headers - the headers that will be included in the request.
        Returns:
        the builder.
      • withCookies

        public HttpRequest.Builder withCookies​(Map<String,​String> cookies)
        Sets the cookies that will be included in the request.
        Parameters:
        cookies - the cookies that will be included in the request.
        Returns:
        the builder.
      • withBody

        public HttpRequest.Builder withBody​(Object body)
        Sets the body that will be included in the request. If encodeBodyAsJson is not set (or is set to false) the body must either be a String or a Binary or else the request will fail when executed on Stitch.
        Parameters:
        body - the body that will be included in the request.
        Returns:
        the builder.
      • withEncodeBodyAsJson

        public HttpRequest.Builder withEncodeBodyAsJson​(Boolean encodeBodyAsJson)
        Sets whether or not the included body should be encoded as extended JSON when sent to the url in this request. Defaults to false.
        Parameters:
        encodeBodyAsJson - whether or not the included body should be encoded as extended JSON when sent to the url in this request.
        Returns:
        the builder.
        See Also:
        withBody
      • withForm

        public HttpRequest.Builder withForm​(Map<String,​String> form)
        Sets the form that will be included in the request.
        Parameters:
        form - the form that will be included in the request.
        Returns:
        the builder.
      • withFollowRedirects

        public HttpRequest.Builder withFollowRedirects​(Boolean followRedirects)
        Sets whether or not Stitch should follow redirects while executing the request. Defaults to false.
        Parameters:
        followRedirects - whether or not Stitch should follow redirects while executing the request. Defaults to false.
        Returns:
        the builder.
      • build

        public HttpRequest build()
        Builds, validates, and returns the HttpRequest.
        Returns:
        the built HTTP request.