Package io.servicetalk.http.api
Interface HttpMetaData
-
- All Known Subinterfaces:
BlockingStreamingHttpRequest
,BlockingStreamingHttpResponse
,HttpRequest
,HttpRequestMetaData
,HttpResponse
,HttpResponseMetaData
,StreamingHttpRequest
,StreamingHttpResponse
- All Known Implementing Classes:
BlockingStreamingHttpServerResponse
public interface HttpMetaData
Meta data shared between requests and responses.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default HttpMetaData
addCookie(HttpCookiePair cookie)
Adds a cookie.default HttpMetaData
addCookie(java.lang.CharSequence name, java.lang.CharSequence value)
default HttpMetaData
addHeader(java.lang.CharSequence name, java.lang.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(java.lang.CharSequence name, java.lang.CharSequence value)
ContentCodec
encoding()
Returns theContentCodec
used to encode the payload of a request or a response.HttpMetaData
encoding(ContentCodec encoding)
TheContentCodec
used to encode the payload of a request or a response.HttpHeaders
headers()
Returns the headers of this message.default HttpMetaData
setHeader(java.lang.CharSequence name, java.lang.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.java.lang.String
toString()
Returns a string representation of the message.default java.lang.String
toString(java.util.function.BiFunction<? super java.lang.CharSequence,? super java.lang.CharSequence,java.lang.CharSequence> headerFilter)
Returns a string representation of the message and headers.HttpProtocolVersion
version()
Returns the protocol version of thisHttpMetaData
.HttpMetaData
version(HttpProtocolVersion version)
Set the protocol version of thisHttpMetaData
.
-
-
-
Method Detail
-
version
HttpProtocolVersion version()
Returns the protocol version of thisHttpMetaData
.- Returns:
- the version.
-
version
HttpMetaData version(HttpProtocolVersion 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
HttpMetaData encoding(ContentCodec encoding)
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 passingContentCodings.identity()
.- Parameters:
encoding
- TheContentCodec
used for the encoding of the payload.- Returns:
this
.- See Also:
- Content-Encoding
-
encoding
@Nullable ContentCodec encoding()
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:
- Content-Encoding
-
addHeader
default HttpMetaData addHeader(java.lang.CharSequence name, java.lang.CharSequence value)
Adds a new header with the specifiedname
andvalue
.- Parameters:
name
- the name of the header.value
- the value of the header.- Returns:
this
.
-
addHeaders
default HttpMetaData addHeaders(HttpHeaders headers)
Adds all header names and values ofheaders
object.- Parameters:
headers
- the headers to add.- Returns:
this
.
-
setHeader
default HttpMetaData setHeader(java.lang.CharSequence name, java.lang.CharSequence value)
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
default HttpMetaData setHeaders(HttpHeaders headers)
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
default HttpMetaData addCookie(HttpCookiePair cookie)
Adds a cookie.This may result in multiple
HttpCookiePair
s with same name.- Parameters:
cookie
- the cookie to add.- Returns:
this
.
-
addCookie
default HttpMetaData addCookie(java.lang.CharSequence name, java.lang.CharSequence value)
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
default HttpMetaData addSetCookie(HttpSetCookie cookie)
Adds a set-cookie.This may result in multiple
HttpSetCookie
s with same name.- Parameters:
cookie
- the cookie to add.- Returns:
this
.
-
addSetCookie
default HttpMetaData addSetCookie(java.lang.CharSequence name, java.lang.CharSequence value)
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
java.lang.String toString()
Returns a string representation of the message. To avoid accidentally logging sensitive information, implementations should not return any header or content.- Overrides:
toString
in classjava.lang.Object
- Returns:
- a string representation of the message
-
toString
default java.lang.String toString(java.util.function.BiFunction<? super java.lang.CharSequence,? super java.lang.CharSequence,java.lang.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
-
-