Package io.servicetalk.http.api
Interface HttpMetaData
- All Superinterfaces:
ContextMapHolder
- All Known Subinterfaces:
BlockingStreamingHttpRequest
,BlockingStreamingHttpResponse
,BlockingStreamingHttpServerResponse
,HttpRequest
,HttpRequestMetaData
,HttpResponse
,HttpResponseMetaData
,StreamingHttpRequest
,StreamingHttpResponse
Meta data shared between requests and responses.
-
Method Summary
Modifier and TypeMethodDescriptiondefault HttpMetaData
addCookie
(HttpCookiePair cookie) Adds a cookie.default HttpMetaData
addCookie
(CharSequence name, CharSequence value) default HttpMetaData
addHeader
(CharSequence name, CharSequence value) Adds a new header with the specifiedname
andvalue
.default HttpMetaData
addHeaders
(HttpHeaders headers) Adds all header names and values ofheaders
object.default HttpMetaData
addSetCookie
(HttpSetCookie cookie) Adds a set-cookie.default HttpMetaData
addSetCookie
(CharSequence name, CharSequence value) context()
A context associated with thisHttpMetaData
.context
(ContextMap context) Sets a context for thisHttpMetaData
.default ContentCodec
encoding()
Deprecated.default HttpMetaData
encoding
(ContentCodec encoding) Deprecated.UseHttpRequestMetaData.contentEncoding(BufferEncoder)
for requests andContentEncodingHttpServiceFilter
for responses.headers()
Returns the headers of this message.default HttpMetaData
setHeader
(CharSequence name, CharSequence value) Sets a header with the specifiedname
andvalue
.default HttpMetaData
setHeaders
(HttpHeaders headers) Clears the current header entries and copies all header entries of the specifiedheaders
object.toString()
Returns a string representation of the message.default String
toString
(BiFunction<? super CharSequence, ? super CharSequence, CharSequence> headerFilter) Returns a string representation of the message and headers.version()
Returns the protocol version of thisHttpMetaData
.version
(HttpProtocolVersion version) Set the protocol version of thisHttpMetaData
.
-
Method Details
-
version
HttpProtocolVersion version()Returns the protocol version of thisHttpMetaData
.- Returns:
- the version.
-
version
Set the protocol version of thisHttpMetaData
.- Parameters:
version
- the protocol version to set.- Returns:
this
.
-
headers
HttpHeaders headers()Returns the headers of this message.- Returns:
- the headers.
-
encoding
Deprecated.UseHttpRequestMetaData.contentEncoding(BufferEncoder)
for requests andContentEncodingHttpServiceFilter
for responses. An example can be found here.TheContentCodec
used to encode the payload of a request or a response. If the endpoint is setup withContentCodingHttpServiceFilter
, the server will auto-establish the accepted encoding for the response, unless the caller provides a specific encoding by calling this method. Any encoding passed here, takes precedence. In other words, a compressed response, can be disabled by passingIdentity.identity()
.- Parameters:
encoding
- TheContentCodec
used for the encoding of the payload.- Returns:
this
.- See Also:
-
encoding
Deprecated.UseHttpRequestMetaData.contentEncoding()
for requests andContentEncodingHttpServiceFilter
for responses. An example can be found here.Returns theContentCodec
used to encode the payload of a request or a response.- Returns:
- The
ContentCodec
used for the encoding of the payload. - See Also:
-
addHeader
Adds a new header with the specifiedname
andvalue
.- Parameters:
name
- the name of the header.value
- the value of the header.- Returns:
this
.
-
addHeaders
Adds all header names and values ofheaders
object.- Parameters:
headers
- the headers to add.- Returns:
this
.
-
setHeader
Sets a header with the specifiedname
andvalue
. Any existing headers with the same name are overwritten.- Parameters:
name
- the name of the header.value
- the value of the header.- Returns:
this
.
-
setHeaders
Clears the current header entries and copies all header entries of the specifiedheaders
object.- Parameters:
headers
- the headers object which contains new values.- Returns:
this
.
-
addCookie
Adds a cookie.This may result in multiple
HttpCookiePair
s with same name.- Parameters:
cookie
- the cookie to add.- Returns:
this
.
-
addCookie
Adds a cookie with the specifiedname
andvalue
.This may result in multiple
HttpSetCookie
s with same name. Added cookie will not be wrapped, not secure, and not HTTP-only, with no path, domain, expire date and maximum age.- Parameters:
name
- the name of the cookie.value
- the value of the cookie.- Returns:
this
.
-
addSetCookie
Adds a set-cookie.This may result in multiple
HttpSetCookie
s with same name.- Parameters:
cookie
- the cookie to add.- Returns:
this
.
-
addSetCookie
Adds a set-cookie with the specifiedname
andvalue
.This may result in multiple
HttpSetCookie
s with same name. Added cookie will not be wrapped, not secure, and not HTTP-only, with no path, domain, expire date and maximum age.- Parameters:
name
- the name of the cookie.value
- the value of the cookie.- Returns:
this
.
-
toString
String toString()Returns a string representation of the message. To avoid accidentally logging sensitive information, implementations should not return any header or content. -
toString
default String toString(BiFunction<? super CharSequence, ? super CharSequence, CharSequence> headerFilter) Returns a string representation of the message and headers.- Parameters:
headerFilter
- a function that accepts the header name and value and returns the filtered value- Returns:
- string representation of the message and headers
-
context
A context associated with thisHttpMetaData
.Context can be used to associate a state with a request or response message without serializing its state on the wire.
- Specified by:
context
in interfaceContextMapHolder
- Returns:
- a context associated with this
HttpMetaData
.
-
context
Sets a context for thisHttpMetaData
.Context can be used to associate a state with a request or response message without serializing its state on the wire.
- Specified by:
context
in interfaceContextMapHolder
- Parameters:
context
- the new context for thisHttpMetaData
.- Returns:
this
.
-
HttpRequestMetaData.contentEncoding()
for requests andContentEncodingHttpServiceFilter
for responses.