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 HttpMetaDataaddCookie(HttpCookiePair cookie) Adds a cookie.default HttpMetaDataaddCookie(CharSequence name, CharSequence value) default HttpMetaDataaddHeader(CharSequence name, CharSequence value) Adds a new header with the specifiednameandvalue.default HttpMetaDataaddHeaders(HttpHeaders headers) Adds all header names and values ofheadersobject.default HttpMetaDataaddSetCookie(HttpSetCookie cookie) Adds a set-cookie.default HttpMetaDataaddSetCookie(CharSequence name, CharSequence value) context()A context associated with thisHttpMetaData.context(ContextMap context) Sets a context for thisHttpMetaData.default ContentCodecencoding()Deprecated.default HttpMetaDataencoding(ContentCodec encoding) Deprecated.UseHttpRequestMetaData.contentEncoding(BufferEncoder)for requests andContentEncodingHttpServiceFilterfor responses.headers()Returns the headers of this message.default HttpMetaDatasetHeader(CharSequence name, CharSequence value) Sets a header with the specifiednameandvalue.default HttpMetaDatasetHeaders(HttpHeaders headers) Clears the current header entries and copies all header entries of the specifiedheadersobject.toString()Returns a string representation of the message.default StringtoString(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 andContentEncodingHttpServiceFilterfor responses. An example can be found here.TheContentCodecused 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- TheContentCodecused for the encoding of the payload.- Returns:
this.- See Also:
-
encoding
Deprecated.UseHttpRequestMetaData.contentEncoding()for requests andContentEncodingHttpServiceFilterfor responses. An example can be found here.Returns theContentCodecused to encode the payload of a request or a response.- Returns:
- The
ContentCodecused for the encoding of the payload. - See Also:
-
addHeader
Adds a new header with the specifiednameandvalue.- Parameters:
name- the name of the header.value- the value of the header.- Returns:
this.
-
addHeaders
Adds all header names and values ofheadersobject.- Parameters:
headers- the headers to add.- Returns:
this.
-
setHeader
Sets a header with the specifiednameandvalue. 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 specifiedheadersobject.- Parameters:
headers- the headers object which contains new values.- Returns:
this.
-
addCookie
Adds a cookie.This may result in multiple
HttpCookiePairs with same name.- Parameters:
cookie- the cookie to add.- Returns:
this.
-
addCookie
Adds a cookie with the specifiednameandvalue.This may result in multiple
HttpSetCookies 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
HttpSetCookies with same name.- Parameters:
cookie- the cookie to add.- Returns:
this.
-
addSetCookie
Adds a set-cookie with the specifiednameandvalue.This may result in multiple
HttpSetCookies 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:
contextin 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:
contextin interfaceContextMapHolder- Parameters:
context- the new context for thisHttpMetaData.- Returns:
this.
-
HttpRequestMetaData.contentEncoding()for requests andContentEncodingHttpServiceFilterfor responses.