Class HttpRequestBuilder

    • Constructor Detail

      • HttpRequestBuilder

        HttpRequestBuilder(HttpRequest request)
    • Method Detail

      • build

         final HttpRequest build()

        Terminate the builder and return the request object

      • path

         final HttpRequestBuilder path(Matcher matcher)

        Sets the path of the request using a matching rule. For example:

        path(regexp("\\/path\\/\\d+", "/path/1000"))
      • header

         HttpRequestBuilder header(String key, Object value)

        Adds a header to the HTTP part. The value will be converted to a string (using the toString() method), unless it is a List. With a List as the value, it will set up a multiple value header. If the value resolves to a single String, and the header key is for a header that has multiple values, the values will be split into a list.

        For example: header("OPTIONS", "GET, POST, PUT") is the same as header("OPTIONS", List.of("GET", "POST, "PUT"))

      • headers

         HttpRequestBuilder headers(String key, String value, String nameValuePairs)

        Adds all the headers to the HTTP part. The values will be converted to a string (using the toString() method), and the header key is for a header that has multiple values, the values will be split into a list.

        For example: headers("OPTIONS", "GET, POST, PUT") is the same as header("OPTIONS", List.of("GET", "POST, "PUT"))

      • headers

         HttpRequestBuilder headers(Pair<String, Object> nameValuePairs)

        Adds all the headers to the HTTP part. The values will be converted to a string (using the toString() method), and the header key is for a header that has multiple values, the values will be split into a list.

        For example: headers("OPTIONS", "GET, POST, PUT") is the same as header("OPTIONS", List.of("GET", "POST, "PUT"))

      • headers

         HttpRequestBuilder headers(Map<String, Object> values)

        Adds all the headers to the HTTP part. You can either pass a Map<String -> String>, and values will be converted to a string (using the toString() method), and the header key is for a header that has multiple values, the values will be split into a list.

        For example: headers(Map<"OPTIONS", "GET, POST, PUT">) is the same as header(Map<"OPTIONS", List<"GET", "POST, "PUT">>))

        Or pass in a Map<String -> List<String>> and no conversion will take place.

      • body

         HttpRequestBuilder body(String body)

        Sets the body of the HTTP part as a string value. If the content type is not already set, it will try to detect the content type from the given string, otherwise will default to text/plain.

      • body

         HttpRequestBuilder body(String body, String contentTypeString)

        Sets the body of the HTTP part as a string value. If the content type is not already set, it will try to detect the content type from the given string, otherwise will default to text/plain.

      • body

         HttpRequestBuilder body(ByteArray body)

        Sets the body of the HTTP part as a byte array. If the content type is not already set, will default to application/octet-stream.

      • body

         HttpRequestBuilder body(ByteArray body, String contentTypeString)

        Sets the body of the HTTP part as a string value. If the content type is not provided or already set, will default to application/octet-stream.

      • queryParameters

         HttpRequestBuilder queryParameters(Map<String, Object> values)

        Adds all the query paraneters to the request. You can either pass a Map<String -> Object>, and values will be converted to a string (using the toString() method), or pass in a Map<String -> List<Object>> multi-value parameters.