Module io.helidon.http
Package io.helidon.http
Interface WritableHeaders<B extends WritableHeaders<B>>
- Type Parameters:
B
- type of the headers (for inheritance)
- All Known Subinterfaces:
ClientRequestHeaders
,ServerResponseHeaders
,ServerResponseTrailers
HTTP Headers that are mutable.
-
Method Summary
Modifier and TypeMethodDescriptionAdd a header or add a header value if the header is already present.default B
add
(HeaderName header, int value) Add a header or add a header value if the header is already present.default B
add
(HeaderName header, long value) Add a header or add a header value if the header is already present.default B
add
(HeaderName header, String... value) Add a header or add a header value if the header is already present.clear()
Clear all current headers.default B
contentLength
(long length) Content length of the entity in bytes.default B
contentType
(MediaType contentType) Sets the MIME type of the response body.static WritableHeaders
<?> create()
Create a new instance of writable headers.static WritableHeaders
<?> Create a new instance of writable headers from existing headers.For each header from the provided headers, set its value on these headers.remove
(HeaderName name) Remove a header.remove
(HeaderName name, Consumer<Header> removedConsumer) Remove a header.Set a header and replace it if it already existed.default B
set
(HeaderName name, int value) Set a header and replace it if it already existed.default B
set
(HeaderName name, long value) Set a header and replace it if it already existed.default B
set
(HeaderName name, String... values) Set a header and replace it if it already existed.default B
set
(HeaderName name, Collection<String> values) Set a header and replace it if it already existed.setIfAbsent
(Header header) Set a value of a header unless it is already present.Methods inherited from interface io.helidon.http.Headers
acceptedTypes, all, contains, contains, contentLength, contentType, first, get, isAccepted, size, stream, toMap, value, values
Methods inherited from interface java.lang.Iterable
forEach, iterator, spliterator
-
Method Details
-
create
Create a new instance of writable headers.- Returns:
- mutable HTTP headers
-
create
Create a new instance of writable headers from existing headers.- Parameters:
headers
- headers to add to the new mutable instance- Returns:
- mutable HTTP headers
-
setIfAbsent
Set a value of a header unless it is already present.- Parameters:
header
- header with value to set- Returns:
- this instance
-
add
Add a header or add a header value if the header is already present.- Parameters:
header
- header with value- Returns:
- this instance
-
add
Add a header or add a header value if the header is already present.- Parameters:
header
- header namevalue
- header value(s)- Returns:
- this instance
-
add
Add a header or add a header value if the header is already present.- Parameters:
header
- header namevalue
- header value- Returns:
- this instance
-
add
Add a header or add a header value if the header is already present.- Parameters:
header
- header namevalue
- header value- Returns:
- this instance
-
remove
Remove a header.- Parameters:
name
- name of the header to remove- Returns:
- this instance
-
remove
Remove a header.- Parameters:
name
- name of the header to removeremovedConsumer
- consumer to be called with existing header; if the header did not exist, consumer will not be called- Returns:
- this instance
-
contentType
Sets the MIME type of the response body.- Parameters:
contentType
- Media type of the content,HttpMediaType
may be used to add parameters- Returns:
- this instance
-
set
Set a header and replace it if it already existed.- Parameters:
header
- header to set- Returns:
- this instance
-
set
Set a header and replace it if it already existed. Useset(Header)
for headers that are known in advance (use a constant), or for headers obtained from Helidon server or client. This method is intended for headers that are unknown or change value often.- Parameters:
name
- header name to setvalues
- value(s) of the header- Returns:
- this instance
-
set
Set a header and replace it if it already existed. Useset(Header)
for headers that are known in advance (use a constant), or for headers obtained from Helidon server or client. This method is intended for headers that are unknown or change value often.- Parameters:
name
- header name to setvalue
- integer value of the header- Returns:
- this instance
-
set
Set a header and replace it if it already existed. Useset(Header)
for headers that are known in advance (use a constant), or for headers obtained from Helidon server or client. This method is intended for headers that are unknown or change value often.- Parameters:
name
- header name to setvalue
- long value of the header- Returns:
- this instance
-
set
Set a header and replace it if it already existed. Useset(Header)
for headers that are known in advance (use a constant), or for headers obtained from Helidon server or client. This method is intended for headers that are unknown or change value often.- Parameters:
name
- header name to setvalues
- value(s) of the header- Returns:
- this instance
-
contentLength
Content length of the entity in bytes. If not configured and a non-streaming entity is used, it will be configured based on the entity length. For streaming entities without content length we switch to chunked encoding (HTTP/1).- Parameters:
length
- length of the entity- Returns:
- this instance
-
clear
B clear()Clear all current headers.- Returns:
- this instance
-
from
For each header from the provided headers, set its value on these headers. If a header exists on these headers and on the provided headers, it would be replaced with the value(s) from provided headers.- Parameters:
headers
- to read headers from and set them on this instance- Returns:
- this instance
-