Interface HttpRequestHeaders
-
- All Known Implementing Classes:
HttpHeadersBuilder
public interface HttpRequestHeaders
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static classHttpRequestHeaders.Headers
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default HttpRequestHeadersaccept(MediaType... acceptableMediaTypes)Set the list of acceptable media types, as specified by theAcceptheader.default HttpRequestHeadersacceptCharset(java.nio.charset.Charset... acceptableCharsets)Set the list of acceptable charsets, as specified by theAccept-Charsetheader.HttpRequestHeadersadd(java.lang.String headerName, java.lang.String headerValue)Adds the given name value pair to the set of headers for this request.default java.util.Optional<MediaType>contentType()Returns an Optional ofmedia typeof the body, as specified by theContent-Typeheader.default HttpRequestHeaderscontentType(MediaType contentType)Sets the MediaType of the body, specified by theContent-Typeheader.voidforEach(java.util.function.BiConsumer<java.lang.String,java.util.List<java.lang.String>> callback)Performs the provided callback for each header.java.util.List<java.lang.String>get(java.lang.String headerName)Get an immutable list of header values for the given header name, possibly empty.default java.util.Optional<java.lang.String>getFirst(java.lang.String headerName)Returns an Optional of the first header value for the given header name, if any.HttpRequestHeadersremove(java.lang.String headerName)Removes the header with the specified name, if present.HttpRequestHeadersset(java.lang.String headerName, java.lang.String... headerValues)Sets the given name value pair to the set of headers for this request.
-
-
-
Method Detail
-
add
HttpRequestHeaders add(java.lang.String headerName, java.lang.String headerValue)
Adds the given name value pair to the set of headers for this request. The given value is added to the list of values for that name.- Parameters:
headerName- the header nameheaderValue- the header value- Returns:
- this instance
-
set
HttpRequestHeaders set(java.lang.String headerName, java.lang.String... headerValues)
Sets the given name value pair to the set of headers for this request.- Parameters:
headerName- the header nameheaderValues- the header values- Returns:
- this instance
-
remove
HttpRequestHeaders remove(java.lang.String headerName)
Removes the header with the specified name, if present.- Parameters:
headerName- the header name- Returns:
- this instance
-
get
java.util.List<java.lang.String> get(java.lang.String headerName)
Get an immutable list of header values for the given header name, possibly empty.- Parameters:
headerName- the header name- Returns:
- the list of header values, or an empty list
-
getFirst
default java.util.Optional<java.lang.String> getFirst(java.lang.String headerName)
Returns an Optional of the first header value for the given header name, if any.- Parameters:
headerName- the header name- Returns:
- an
Optionalof first header value orOptional.empty()if none
-
contentType
default java.util.Optional<MediaType> contentType()
Returns an Optional ofmedia typeof the body, as specified by theContent-Typeheader.- Returns:
- an
Optionalof the of theContent-Typeheader
-
contentType
default HttpRequestHeaders contentType(MediaType contentType)
Sets the MediaType of the body, specified by theContent-Typeheader. Can be null.- Returns:
- this instance
-
accept
default HttpRequestHeaders accept(MediaType... acceptableMediaTypes)
Set the list of acceptable media types, as specified by theAcceptheader.- Parameters:
acceptableMediaTypes- the acceptable media types- Returns:
- this instance
-
acceptCharset
default HttpRequestHeaders acceptCharset(java.nio.charset.Charset... acceptableCharsets)
Set the list of acceptable charsets, as specified by theAccept-Charsetheader.- Parameters:
acceptableCharsets- the acceptable charsets- Returns:
- this builder
-
forEach
void forEach(java.util.function.BiConsumer<java.lang.String,java.util.List<java.lang.String>> callback)
Performs the provided callback for each header.
-
-