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 HttpMetaDataMeta data shared between requests and responses.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default HttpMetaDataaddCookie(HttpCookiePair cookie)Adds a cookie.default HttpMetaDataaddCookie(java.lang.CharSequence name, java.lang.CharSequence value)default HttpMetaDataaddHeader(java.lang.CharSequence name, java.lang.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(java.lang.CharSequence name, java.lang.CharSequence value)ContentCodecencoding()Returns theContentCodecused to encode the payload of a request or a response.HttpMetaDataencoding(ContentCodec encoding)TheContentCodecused to encode the payload of a request or a response.HttpHeadersheaders()Returns the headers of this message.default HttpMetaDatasetHeader(java.lang.CharSequence name, java.lang.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.java.lang.StringtoString()Returns a string representation of the message.default java.lang.StringtoString(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.HttpProtocolVersionversion()Returns the protocol version of thisHttpMetaData.HttpMetaDataversion(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)
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:
- Content-Encoding
-
encoding
@Nullable ContentCodec encoding()
Returns theContentCodecused to encode the payload of a request or a response.- Returns:
- The
ContentCodecused 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 specifiednameandvalue.- 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 ofheadersobject.- 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 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
default HttpMetaData setHeaders(HttpHeaders headers)
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
default HttpMetaData addCookie(HttpCookiePair cookie)
Adds a cookie.This may result in multiple
HttpCookiePairs 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 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
default HttpMetaData addSetCookie(HttpSetCookie cookie)
Adds a set-cookie.This may result in multiple
HttpSetCookies 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 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
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:
toStringin 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
-
-