Interface RequestHeaderContainer.Builder
- All Known Implementing Classes:
DefaultRequestHeaderContainer.Builder
- Enclosing interface:
- RequestHeaderContainer
public static interface RequestHeaderContainer.Builder
Convenience class for constructing and manipulating
RequestHeaderContainer
s.-
Method Summary
Modifier and TypeMethodDescriptionbuild()
Initializes a new instance ofRequestHeaderContainer
from the HTTP headers and cookies contained in thisRequestHeaderContainer.Builder
.clear()
Removes all HTTP headers and cookies from thisRequestHeaderContainer.Builder
.replaceHeader
(String name, RequestHeaderContainer headerContainer) Replaces an HTTP header in thisRequestHeaderContainer.Builder
by copying the HTTP header of the givenheaderContainer
.replaceHeader
(String name, Iterable<String> values) Replaces an HTTP header in thisRequestHeaderContainer.Builder
.replaceHeader
(String name, String firstValue, String... furtherValues) Replaces an HTTP header in thisRequestHeaderContainer.Builder
.withHeader
(String name, RequestHeaderContainer headerContainer) Copies the HTTP header with the givenname
- including all it's values - from theheaderContainer
.withHeader
(String name, Iterable<String> values) Adds a new HTTP header with the given values to thisRequestHeaderContainer.Builder
.withHeader
(String name, String firstValue, String... furtherValues) Adds a new HTTP header with the given values to thisRequestHeaderContainer.Builder
.withHeaders
(RequestHeaderContainer headerContainer) Copies all existing headers from the givenRequestHeaderContainer
.withoutHeader
(String name) Removes an HTTP header from thisRequestHeaderContainer.Builder
.
-
Method Details
-
withHeaders
@Nonnull RequestHeaderContainer.Builder withHeaders(@Nonnull RequestHeaderContainer headerContainer) Copies all existing headers from the givenRequestHeaderContainer
.- Parameters:
headerContainer
- TheRequestHeaderContainer
to copy the headers from.- Returns:
- This
RequestHeaderContainer.Builder
instance.
-
withHeader
@Nonnull RequestHeaderContainer.Builder withHeader(@Nonnull String name, @Nonnull String firstValue, @Nonnull String... furtherValues) Adds a new HTTP header with the given values to thisRequestHeaderContainer.Builder
.If the header does already exist, all given values will be added to it.
- Parameters:
name
- The name of the HTTP header. This is treated case insensitively.firstValue
- The first value of the HTTP header.furtherValues
- Further values of the HTTP header.- Returns:
- This
RequestHeaderContainer.Builder
instance.
-
withHeader
@Nonnull RequestHeaderContainer.Builder withHeader(@Nonnull String name, @Nonnull Iterable<String> values) Adds a new HTTP header with the given values to thisRequestHeaderContainer.Builder
.If the header does already exist, all given values will be added to it.
- Parameters:
name
- The name of the HTTP header. This is treated case insensitively.values
- The values of the HTTP header.- Returns:
- This
RequestHeaderContainer.Builder
instance.
-
withHeader
@Nonnull RequestHeaderContainer.Builder withHeader(@Nonnull String name, @Nonnull RequestHeaderContainer headerContainer) Copies the HTTP header with the givenname
- including all it's values - from theheaderContainer
.- Parameters:
name
- The name of the HTTP header.headerContainer
- TheRequestHeaderContainer
to copy the HTTP header from.- Returns:
- This
RequestHeaderContainer.Builder
instance.
-
withoutHeader
Removes an HTTP header from thisRequestHeaderContainer.Builder
.- Parameters:
name
- The case insensitive name of the HTTP header.- Returns:
- This
RequestHeaderContainer.Builder
instance.
-
replaceHeader
@Nonnull RequestHeaderContainer.Builder replaceHeader(@Nonnull String name, @Nonnull String firstValue, @Nonnull String... furtherValues) Replaces an HTTP header in thisRequestHeaderContainer.Builder
.This method is semantically equivalent to
withoutHeader(name).withHeader(name, firstValue, furtherValues)
.- Parameters:
name
- The case insensitive name of the HTTP header.firstValue
- The first new value of the HTTP header.furtherValues
- Further new values of the HTTP header.- Returns:
- This
RequestHeaderContainer.Builder
instance.
-
replaceHeader
@Nonnull RequestHeaderContainer.Builder replaceHeader(@Nonnull String name, @Nonnull Iterable<String> values) Replaces an HTTP header in thisRequestHeaderContainer.Builder
.This method is semantically equivalent to
withoutHeader(name).withHeader(name, values)
.- Parameters:
name
- The case insensitive name of the HTTP header.values
- The new values of the HTTP header.- Returns:
- This
RequestHeaderContainer.Builder
instance.
-
replaceHeader
@Nonnull RequestHeaderContainer.Builder replaceHeader(@Nonnull String name, @Nonnull RequestHeaderContainer headerContainer) Replaces an HTTP header in thisRequestHeaderContainer.Builder
by copying the HTTP header of the givenheaderContainer
.This method is equivalent to
withoutHeader(name).withHeader(name, headerContainer)
.- Parameters:
name
- The case insensitive name of the HTTP header.headerContainer
- TheRequestHeaderContainer
to copy the HTTP header from.- Returns:
- This
RequestHeaderContainer.Builder
instance.
-
clear
Removes all HTTP headers and cookies from thisRequestHeaderContainer.Builder
.- Returns:
- This
RequestHeaderContainer.Builder
instance.
-
build
Initializes a new instance ofRequestHeaderContainer
from the HTTP headers and cookies contained in thisRequestHeaderContainer.Builder
.- Returns:
- A new instance of
RequestHeaderContainer
.
-