Class HttpResponseBuilder

    • Constructor Detail

      • HttpResponseBuilder

        HttpResponseBuilder(HttpResponse response)
    • Method Detail

      • build

         final HttpResponse build()

        Terminate the builder and return the response object

      • header

         HttpResponseBuilder 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

         HttpResponseBuilder 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

         HttpResponseBuilder 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

         HttpResponseBuilder 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

         HttpResponseBuilder 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

         HttpResponseBuilder 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

         HttpResponseBuilder 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

         HttpResponseBuilder 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.