Class HttpPartBuilder
-
- All Implemented Interfaces:
public abstract class HttpPartBuilder
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public classHttpPartBuilder.Companion
-
Field Summary
Fields Modifier and Type Field Description public final static HttpPartBuilder.CompanionCompanion
-
Constructor Summary
Constructors Constructor Description HttpPartBuilder(IHttpPart part)
-
Method Summary
Modifier and Type Method Description HttpPartBuilderheader(String key, Object value)Adds a header to the HTTP part. HttpPartBuilderheaders(String key, String value, Array<out String> nameValuePairs)Adds all the headers to the HTTP part. HttpPartBuilderheaders(Array<out Pair<String, Object>> nameValuePairs)Adds all the headers to the HTTP part. HttpPartBuilderheaders(Map<String, Object> values)Adds all the headers to the HTTP part. HttpPartBuilderbody(String body)Sets the body of the HTTP part as a string value. HttpPartBuilderbody(String body, String contentTypeString)Sets the body of the HTTP part as a string value. HttpPartBuilderbody(ByteArray body)Sets the body of the HTTP part as a byte array. HttpPartBuilderbody(ByteArray body, String contentTypeString)Sets the body of the HTTP part as a string value. HttpPartBuilderbody(DslPart dslPart)Sets the body, content type and matching rules from a DslPart HttpPartBuilderbody(BodyBuilder builder)Sets the body, content type and matching rules from a BodyBuilder HttpPartBuilderbodyMatchingContentType(String contentType, ByteArray exampleContents)Sets up a content type matcher to match any body of the given content type HttpPartBuilderbodyMatchingContentType(String contentType, String exampleContents)Sets up a content type matcher to match any body of the given content type -
-
Method Detail
-
header
HttpPartBuilder 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 asheader("OPTIONS", List.of("GET", "POST, "PUT"))
-
headers
HttpPartBuilder headers(String key, String value, Array<out 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 asheader("OPTIONS", List.of("GET", "POST, "PUT"))
-
headers
HttpPartBuilder headers(Array<out 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 asheader("OPTIONS", List.of("GET", "POST, "PUT"))
-
headers
HttpPartBuilder 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 asheader(Map<"OPTIONS", List<"GET", "POST, "PUT">>))Or pass in a Map<String -> List<String>> and no conversion will take place.
-
body
HttpPartBuilder 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
HttpPartBuilder 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
HttpPartBuilder 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
HttpPartBuilder 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.
-
body
HttpPartBuilder body(DslPart dslPart)
Sets the body, content type and matching rules from a DslPart
-
body
HttpPartBuilder body(BodyBuilder builder)
Sets the body, content type and matching rules from a BodyBuilder
-
bodyMatchingContentType
HttpPartBuilder bodyMatchingContentType(String contentType, ByteArray exampleContents)
Sets up a content type matcher to match any body of the given content type
-
bodyMatchingContentType
HttpPartBuilder bodyMatchingContentType(String contentType, String exampleContents)
Sets up a content type matcher to match any body of the given content type
-
-
-
-