Module org.mule.sdk.api
Interface HttpMessageBuilder<Builder extends HttpMessageBuilder,Message extends HttpMessage>
- Type Parameters:
Builder- the type of the builder itself.Message- the type ofHttpMessagethat the builder creates.
- All Known Subinterfaces:
HttpRequestBuilder,HttpResponseBuilder
@Experimental
@NoImplement
@MinMuleVersion("4.10.0")
public interface HttpMessageBuilder<Builder extends HttpMessageBuilder,Message extends HttpMessage>
Base implementation of an
HttpMessage builder. Implementations should extend it and indicate their type and the type of
the message they build.- Since:
- 0.12.0
-
Method Summary
Modifier and TypeMethodDescriptionIncludes a new header to be sent in the desiredHttpMessage.addHeaders(String name, Collection<String> values) Includes a new header with multiple values to be sent in the desiredHttpMessage.build()Discard this builder after calling this method.entity(HttpEntity entity) getHeaderValue(String name) Returns the value of a given HTTP request.getHeaderValues(String name) Gives access to all current values of a given HTTP header.removeHeader(String name) Removes a header.
-
Method Details
-
entity
- Parameters:
entity- theHttpEntitythat should be used as body for theHttpMessage. Non null.- Returns:
- this builder
-
headers
- Parameters:
headersMap- aMultiMaprepresenting the HTTP headers of theHttpMessagedesired. Non-null.- Returns:
- this builder
-
addHeader
Includes a new header to be sent in the desiredHttpMessage. Since HTTP headers are case insensitive and can have several values, multiple calls to this method using the same header name will accumulate the values and all of them will be sent.- Parameters:
name- the name of the HTTP headervalue- the value of the HTTP header- Returns:
- this builder
-
addHeaders
Includes a new header with multiple values to be sent in the desiredHttpMessage.- Parameters:
name- the name of the HTTP headervalues- the values of the HTTP header- Returns:
- this builder
-
removeHeader
Removes a header. Since multiple values might be present, all are removed.- Parameters:
name- the name of the HTTP header to remove- Returns:
- this builder
-
getHeaderValue
Returns the value of a given HTTP request. If there are several then the first will be return. UsegetHeaderValues(String)instead if all values are required.- Parameters:
name- the name of the desired HTTP header- Returns:
- the value of the header or
nullif there isn't one
-
getHeaderValues
Gives access to all current values of a given HTTP header.- Parameters:
name- the name of the desired HTTP header- Returns:
- an immutable
CollectionofStringvalues for the header
-
getHeaders
- Returns:
- an immutable version of the current headers in the builder.
-
build
Message build()Discard this builder after calling this method.
-