Module io.helidon.common.http
Package io.helidon.common.http
Interface WritableHeaders<B extends WritableHeaders<B>>
- Type Parameters:
B- type of the headers (for inheritance)
- All Superinterfaces:
Headers,Iterable<Http.HeaderValue>
- All Known Subinterfaces:
ClientRequestHeaders,ServerResponseHeaders
HTTP Headers that are mutable.
-
Method Summary
Modifier and TypeMethodDescriptiondefault Badd(Http.HeaderName header, String... value) Add a header or add a header value if the header is already present.add(Http.HeaderValue header) Add a header or add a header value if the header is already present.clear()Clear all current headers.default BcontentLength(long length) Content length of the entity in bytes.default BcontentType(HttpMediaType contentType) Sets the MIME type of the response body.default BcontentType(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.remove(Http.HeaderName name) Remove a header.remove(Http.HeaderName name, Consumer<Http.HeaderValue> removedConsumer) Remove a header.default Bset(Http.HeaderName name, String... values) Set a header and replace it if it already existed.default Bset(Http.HeaderName name, List<String> values) Set a header and replace it if it already existed.set(Http.HeaderValue header) Set a header and replace it if it already existed.setIfAbsent(Http.HeaderValue header) Set a value of a header unless it is already present.Methods inherited from interface io.helidon.common.http.Headers
acceptedTypes, all, all, contains, contains, contentLength, contentType, first, get, isAccepted, size, toMap, value, valuesMethods 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
-
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.- Returns:
- this instance
-
contentType
Sets the MIME type of the response body.- Parameters:
contentType- Media type of the content.- 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(io.helidon.common.http.Http.HeaderValue)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(io.helidon.common.http.Http.HeaderValue)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
-