Interface StreamingHttpRequest
-
- All Superinterfaces:
HttpMetaData,HttpRequestMetaData
public interface StreamingHttpRequest extends HttpRequestMetaData
The equivalent ofHttpRequestbut provides the payload as aPublisher.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Deprecated Methods Modifier and Type Method Description default StreamingHttpRequestaddCookie(HttpCookiePair cookie)Adds a cookie.default StreamingHttpRequestaddCookie(java.lang.CharSequence name, java.lang.CharSequence value)default StreamingHttpRequestaddHeader(java.lang.CharSequence name, java.lang.CharSequence value)Adds a new header with the specifiednameandvalue.default StreamingHttpRequestaddHeaders(HttpHeaders headers)Adds all header names and values ofheadersobject.StreamingHttpRequestaddQueryParameter(java.lang.String key, java.lang.String value)Adds a new query parameter with the specifiedkeyandvalue, which will be percent-encoded if needed.StreamingHttpRequestaddQueryParameters(java.lang.String key, java.lang.Iterable<java.lang.String> values)Adds new query parameters with the specifiedkeyandvalues.StreamingHttpRequestaddQueryParameters(java.lang.String key, java.lang.String... values)Adds new query parameters with the specifiedkeyandvalues.default StreamingHttpRequestaddSetCookie(HttpSetCookie cookie)Adds a set-cookie.default StreamingHttpRequestaddSetCookie(java.lang.CharSequence name, java.lang.CharSequence value)StreamingHttpRequestappendPathSegments(java.lang.String... segments)Appends segments to the currentHttpRequestMetaData.path(), performing encoding of each segment (including ('/') characters) according to percent-encoding.StreamingHttpRequestencoding(ContentCodec encoding)TheContentCodecused to encode the payload of a request or a response.Publisher<java.lang.Object>messageBody()Get the message-body which contains the payload body concatenated with the trailer (if present).StreamingHttpRequestmethod(HttpRequestMethod method)Set theHttpRequestMethodof thisStreamingHttpRequest.StreamingHttpRequestpath(java.lang.String path)Sets the path, performing encoding according to percent-encoding, except for forward-slash ('/') characters.Publisher<Buffer>payloadBody()StreamingHttpRequestpayloadBody(Publisher<Buffer> payloadBody)Returns aStreamingHttpRequestwith its underlying payload set topayloadBody.<T> StreamingHttpRequestpayloadBody(Publisher<T> payloadBody, HttpSerializer<T> serializer)Returns aStreamingHttpRequestwith its underlying payload set to the result of serialization.default <T> Publisher<T>payloadBody(HttpDeserializer<T> deserializer)Gets and deserializes the payload body.Publisher<java.lang.Object>payloadBodyAndTrailers()Deprecated.UsemessageBody().StreamingHttpRequestquery(java.lang.String query)Sets the path, performing encoding according to rfc3986, Query.StreamingHttpRequestrawPath(java.lang.String path)Sets the path topath, without any encoding performed.StreamingHttpRequestrawQuery(java.lang.String query)Sets the query component toquery, without any encoding performed.StreamingHttpRequestrequestTarget(java.lang.String requestTarget)Set the request-target.StreamingHttpRequestrequestTarget(java.lang.String requestTarget, java.nio.charset.Charset encoding)Set the request-target.default StreamingHttpRequestsetHeader(java.lang.CharSequence name, java.lang.CharSequence value)Sets a header with the specifiednameandvalue.default StreamingHttpRequestsetHeaders(HttpHeaders headers)Clears the current header entries and copies all header entries of the specifiedheadersobject.StreamingHttpRequestsetQueryParameter(java.lang.String key, java.lang.String value)StreamingHttpRequestsetQueryParameters(java.lang.String key, java.lang.Iterable<java.lang.String> values)Sets new query parameters with the specifiedkeyandvalues.StreamingHttpRequestsetQueryParameters(java.lang.String key, java.lang.String... values)Sets new query parameters with the specifiedkeyandvalues.BlockingStreamingHttpRequesttoBlockingStreamingRequest()Translate thisStreamingHttpRequestto aBlockingStreamingHttpRequest.Single<HttpRequest>toRequest()Translates thisStreamingHttpRequestto aHttpRequest.<T> StreamingHttpRequesttransform(TrailersTransformer<T,Buffer> trailersTransformer)Returns aStreamingHttpRequestwith its underlying payload transformed toBuffers, with access to the trailers.StreamingHttpRequesttransformMessageBody(java.util.function.UnaryOperator<Publisher<?>> transformer)Transform the message-body which contains the payload body concatenated with the trailer (if present).<T> StreamingHttpRequesttransformPayloadBody(java.util.function.Function<Publisher<Buffer>,Publisher<T>> transformer, HttpSerializer<T> serializer)Returns aStreamingHttpRequestwith its underlying payload transformed to the result of serialization.default <T,R>
StreamingHttpRequesttransformPayloadBody(java.util.function.Function<Publisher<T>,Publisher<R>> transformer, HttpDeserializer<T> deserializer, HttpSerializer<R> serializer)Returns aStreamingHttpRequestwith its underlying payload transformed to the result of serialization.StreamingHttpRequesttransformPayloadBody(java.util.function.UnaryOperator<Publisher<Buffer>> transformer)Returns aStreamingHttpRequestwith its underlying payload transformed toBuffers.<T> StreamingHttpRequesttransformRaw(TrailersTransformer<T,java.lang.Object> trailersTransformer)Deprecated.StreamingHttpRequesttransformRawPayloadBody(java.util.function.UnaryOperator<Publisher<?>> transformer)Deprecated.StreamingHttpRequestversion(HttpProtocolVersion version)Set the protocol version of thisHttpMetaData.-
Methods inherited from interface io.servicetalk.http.api.HttpMetaData
encoding, headers, toString, toString, version
-
Methods inherited from interface io.servicetalk.http.api.HttpRequestMetaData
effectiveHostAndPort, hasQueryParameter, hasQueryParameter, host, method, path, port, query, queryParameter, queryParameters, queryParameters, queryParametersIterator, queryParametersKeys, queryParametersSize, rawPath, rawQuery, removeQueryParameters, removeQueryParameters, requestTarget, requestTarget, scheme, userInfo
-
-
-
-
Method Detail
-
payloadBody
default <T> Publisher<T> payloadBody(HttpDeserializer<T> deserializer)
Gets and deserializes the payload body.- Type Parameters:
T- The resulting type of the deserialization operation.- Parameters:
deserializer- The function that deserializes the underlyingPublisher.- Returns:
- The results of the deserialization operation.
-
payloadBodyAndTrailers
@Deprecated Publisher<java.lang.Object> payloadBodyAndTrailers()
Deprecated.UsemessageBody().
-
messageBody
Publisher<java.lang.Object> messageBody()
Get the message-body which contains the payload body concatenated with the trailer (if present).- Returns:
- a
Publisherthat represents the message-body which contains the payload body concatenated with the trailer (if present).
-
payloadBody
StreamingHttpRequest payloadBody(Publisher<Buffer> payloadBody)
Returns aStreamingHttpRequestwith its underlying payload set topayloadBody.A best effort will be made to apply back pressure to the existing
Publisherpayload body. If this default policy is not sufficient you can usetransformPayloadBody(UnaryOperator)for more fine grain control.This method reserves the right to delay completion/consumption of
payloadBody. This may occur due to the combination with the existingPublisherpayload body.- Parameters:
payloadBody- The new payload body.- Returns:
this
-
payloadBody
<T> StreamingHttpRequest payloadBody(Publisher<T> payloadBody, HttpSerializer<T> serializer)
Returns aStreamingHttpRequestwith its underlying payload set to the result of serialization.A best effort will be made to apply back pressure to the existing
Publisherpayload body. If this default policy is not sufficient you can usetransformPayloadBody(Function, HttpSerializer)for more fine grain control.This method reserves the right to delay completion/consumption of
payloadBody. This may occur due to the combination with the existingPublisherpayload body.- Type Parameters:
T- The type of objects to serialize.- Parameters:
payloadBody- The new payload body, prior to serialization.serializer- Used to serialize the payload body.- Returns:
this
-
transformPayloadBody
<T> StreamingHttpRequest transformPayloadBody(java.util.function.Function<Publisher<Buffer>,Publisher<T>> transformer, HttpSerializer<T> serializer)
Returns aStreamingHttpRequestwith its underlying payload transformed to the result of serialization.- Type Parameters:
T- The type of objects to serialize.- Parameters:
transformer- AFunctionwhich take as a parameter the existing payload bodyPublisherand returns the new payload bodyPublisherprior to serialization. It is assumed the existing payload bodyPublisherwill be transformed/consumed or else no more requests may be processed.serializer- Used to serialize the payload body.- Returns:
this
-
transformPayloadBody
default <T,R> StreamingHttpRequest transformPayloadBody(java.util.function.Function<Publisher<T>,Publisher<R>> transformer, HttpDeserializer<T> deserializer, HttpSerializer<R> serializer)
Returns aStreamingHttpRequestwith its underlying payload transformed to the result of serialization.- Type Parameters:
T- The type of objects to deserialize.R- The type of objects to serialize.- Parameters:
transformer- AFunctionwhich take as a parameter the existing payload bodyPublisherand returns the new payload bodyPublisherprior to serialization. It is assumed the existing payload bodyPublisherwill be transformed/consumed or else no more requests may be processed.deserializer- Used to deserialize the existing payload body.serializer- Used to serialize the payload body.- Returns:
this
-
transformPayloadBody
StreamingHttpRequest transformPayloadBody(java.util.function.UnaryOperator<Publisher<Buffer>> transformer)
Returns aStreamingHttpRequestwith its underlying payload transformed toBuffers.
-
transformRawPayloadBody
@Deprecated StreamingHttpRequest transformRawPayloadBody(java.util.function.UnaryOperator<Publisher<?>> transformer)
Deprecated.Returns aStreamingHttpRequestwith its underlying payload transformed. Note that the raw objects of the underlyingPublishermay be exposed. The object types are not guaranteed to be homogeneous.- Parameters:
transformer- Responsible for transforming the payload body.- Returns:
this
-
transformMessageBody
StreamingHttpRequest transformMessageBody(java.util.function.UnaryOperator<Publisher<?>> transformer)
Transform the message-body which contains the payload body concatenated with the trailer (if present).The transformation is not expected to change the presence of trailers in the message body. For example behavior is undefined if a
HttpHeadersobject is inserted to or removed from to the returnedPublisher. To add trailers usetransform(TrailersTransformer).- Parameters:
transformer- Responsible for transforming the message-body.- Returns:
this.
-
transform
<T> StreamingHttpRequest transform(TrailersTransformer<T,Buffer> trailersTransformer)
Returns aStreamingHttpRequestwith its underlying payload transformed toBuffers, with access to the trailers.- Type Parameters:
T- The type of state used during the transformation.- Parameters:
trailersTransformer-TrailersTransformerto use for this transform.- Returns:
this
-
transformRaw
@Deprecated <T> StreamingHttpRequest transformRaw(TrailersTransformer<T,java.lang.Object> trailersTransformer)
Deprecated.Returns aStreamingHttpRequestwith its underlying payload transformed toObjects, with access to the trailers.- Type Parameters:
T- The type of state used during the transformation.- Parameters:
trailersTransformer-TrailersTransformerto use for this transform.- Returns:
this
-
toRequest
Single<HttpRequest> toRequest()
Translates thisStreamingHttpRequestto aHttpRequest.- Returns:
- a
Singlethat completes with aHttpRequestrepresentation of thisStreamingHttpRequest.
-
toBlockingStreamingRequest
BlockingStreamingHttpRequest toBlockingStreamingRequest()
Translate thisStreamingHttpRequestto aBlockingStreamingHttpRequest.- Returns:
- a
BlockingStreamingHttpRequestrepresentation of thisStreamingHttpRequest.
-
rawPath
StreamingHttpRequest rawPath(java.lang.String path)
Description copied from interface:HttpRequestMetaDataSets the path topath, without any encoding performed. This assumes that any characters that require encoding have been encoded according to percent-encoding by the caller.Because this modifies the request target, this may result in the clearing of internal caches. See
HttpRequestMetaData.requestTarget(String).- Specified by:
rawPathin interfaceHttpRequestMetaData- Parameters:
path- the encoded path to set.- Returns:
this.
-
path
StreamingHttpRequest path(java.lang.String path)
Description copied from interface:HttpRequestMetaDataSets the path, performing encoding according to percent-encoding, except for forward-slash ('/') characters. This allows forpath("/abc")without it turning into'%2Fabc'.- Specified by:
pathin interfaceHttpRequestMetaData- Parameters:
path- the un-encoded path to set.- Returns:
this.
-
appendPathSegments
StreamingHttpRequest appendPathSegments(java.lang.String... segments)
Description copied from interface:HttpRequestMetaDataAppends segments to the currentHttpRequestMetaData.path(), performing encoding of each segment (including ('/') characters) according to percent-encoding. A/is used to separate each segment and between the currentHttpRequestMetaData.path()and the following segments.- Specified by:
appendPathSegmentsin interfaceHttpRequestMetaData- Parameters:
segments- the un-encoded path to set.- Returns:
this.
-
rawQuery
StreamingHttpRequest rawQuery(@Nullable java.lang.String query)
Description copied from interface:HttpRequestMetaDataSets the query component toquery, without any encoding performed. This assumes that any characters that require encoding have been encoded according to percent-encoding by the caller.Because this modifies the request target, this may result in the clearing of internal caches. See
HttpRequestMetaData.requestTarget(String).- Specified by:
rawQueryin interfaceHttpRequestMetaData- Parameters:
query- the encoded query to set.nullwill clear the query value (e.g. no?present inHttpRequestMetaData.requestTarget().- Returns:
this.
-
query
StreamingHttpRequest query(@Nullable java.lang.String query)
Description copied from interface:HttpRequestMetaDataSets the path, performing encoding according to rfc3986, Query.- Specified by:
queryin interfaceHttpRequestMetaData- Parameters:
query- the un-encoded query to set.nullwill clear the query value (e.g. no?present inHttpRequestMetaData.requestTarget().- Returns:
this.
-
addQueryParameter
StreamingHttpRequest addQueryParameter(java.lang.String key, java.lang.String value)
Description copied from interface:HttpRequestMetaDataAdds a new query parameter with the specifiedkeyandvalue, which will be percent-encoded if needed.- Specified by:
addQueryParameterin interfaceHttpRequestMetaData- Parameters:
key- the query parameter key.value- the query parameter value.- Returns:
this.
-
addQueryParameters
StreamingHttpRequest addQueryParameters(java.lang.String key, java.lang.Iterable<java.lang.String> values)
Description copied from interface:HttpRequestMetaDataAdds new query parameters with the specifiedkeyandvalues. This method is semantically equivalent to:for (T value : values) { addQueryParameter(key, value); }- Specified by:
addQueryParametersin interfaceHttpRequestMetaData- Parameters:
key- the query parameter key.values- the query parameter values.- Returns:
this.
-
addQueryParameters
StreamingHttpRequest addQueryParameters(java.lang.String key, java.lang.String... values)
Description copied from interface:HttpRequestMetaDataAdds new query parameters with the specifiedkeyandvalues. This method is semantically equivalent to:for (T value : values) { query.addQueryParameter(key, value); }- Specified by:
addQueryParametersin interfaceHttpRequestMetaData- Parameters:
key- the query parameter key.values- the query parameter values.- Returns:
this.
-
setQueryParameter
StreamingHttpRequest setQueryParameter(java.lang.String key, java.lang.String value)
Description copied from interface:HttpRequestMetaDataSets a query parameter with the specifiedkeyandvalue, which will be percent-encoded if needed. Any existing query parameters with the same key are overwritten.- Specified by:
setQueryParameterin interfaceHttpRequestMetaData- Parameters:
key- the query parameter key.value- the query parameter value.- Returns:
this.
-
setQueryParameters
StreamingHttpRequest setQueryParameters(java.lang.String key, java.lang.Iterable<java.lang.String> values)
Description copied from interface:HttpRequestMetaDataSets new query parameters with the specifiedkeyandvalues. This method is equivalent to:removeQueryParameter(key); for (T value : values) { query.addQueryParameter(key, value); }- Specified by:
setQueryParametersin interfaceHttpRequestMetaData- Parameters:
key- the query parameter key.values- the query parameter values.- Returns:
this.
-
setQueryParameters
StreamingHttpRequest setQueryParameters(java.lang.String key, java.lang.String... values)
Description copied from interface:HttpRequestMetaDataSets new query parameters with the specifiedkeyandvalues. This method is equivalent to:removeQueryParameter(key); for (T value : values) { query.addQueryParameter(key, value); }- Specified by:
setQueryParametersin interfaceHttpRequestMetaData- Parameters:
key- the query parameter key.values- the query parameter values.- Returns:
this.
-
version
StreamingHttpRequest version(HttpProtocolVersion version)
Description copied from interface:HttpMetaDataSet the protocol version of thisHttpMetaData.- Specified by:
versionin interfaceHttpMetaData- Specified by:
versionin interfaceHttpRequestMetaData- Parameters:
version- the protocol version to set.- Returns:
this.
-
method
StreamingHttpRequest method(HttpRequestMethod method)
Description copied from interface:HttpRequestMetaDataSet theHttpRequestMethodof thisStreamingHttpRequest.- Specified by:
methodin interfaceHttpRequestMetaData- Parameters:
method- theHttpRequestMethodto set.- Returns:
this.
-
encoding
StreamingHttpRequest encoding(ContentCodec encoding)
Description copied from interface:HttpMetaDataTheContentCodecused 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().- Specified by:
encodingin interfaceHttpMetaData- Parameters:
encoding- TheContentCodecused for the encoding of the payload.- Returns:
this.- See Also:
- Content-Encoding
-
requestTarget
StreamingHttpRequest requestTarget(java.lang.String requestTarget)
Description copied from interface:HttpRequestMetaDataSet the request-target.This will be treated as encoded according to percent-encoding.
This may result in clearing of internal caches used by methods that are derived from the
request-target, such asHttpRequestMetaData.path(),HttpRequestMetaData.rawQuery(), etc.- Specified by:
requestTargetin interfaceHttpRequestMetaData- Parameters:
requestTarget- the percent-encoded request-target to set.- Returns:
this.
-
requestTarget
StreamingHttpRequest requestTarget(java.lang.String requestTarget, java.nio.charset.Charset encoding)
Description copied from interface:HttpRequestMetaDataSet the request-target.This may result in clearing of internal caches used by methods that are derived from the
request-target, such asHttpRequestMetaData.path(),HttpRequestMetaData.rawQuery(), etc.- Specified by:
requestTargetin interfaceHttpRequestMetaData- Parameters:
requestTarget- the request-target to set.encoding- theCharsetto use to encoderequestTargetbefore setting the value.- Returns:
this.
-
addHeader
default StreamingHttpRequest addHeader(java.lang.CharSequence name, java.lang.CharSequence value)
Description copied from interface:HttpMetaDataAdds a new header with the specifiednameandvalue.- Specified by:
addHeaderin interfaceHttpMetaData- Specified by:
addHeaderin interfaceHttpRequestMetaData- Parameters:
name- the name of the header.value- the value of the header.- Returns:
this.
-
addHeaders
default StreamingHttpRequest addHeaders(HttpHeaders headers)
Description copied from interface:HttpMetaDataAdds all header names and values ofheadersobject.- Specified by:
addHeadersin interfaceHttpMetaData- Specified by:
addHeadersin interfaceHttpRequestMetaData- Parameters:
headers- the headers to add.- Returns:
this.
-
setHeader
default StreamingHttpRequest setHeader(java.lang.CharSequence name, java.lang.CharSequence value)
Description copied from interface:HttpMetaDataSets a header with the specifiednameandvalue. Any existing headers with the same name are overwritten.- Specified by:
setHeaderin interfaceHttpMetaData- Specified by:
setHeaderin interfaceHttpRequestMetaData- Parameters:
name- the name of the header.value- the value of the header.- Returns:
this.
-
setHeaders
default StreamingHttpRequest setHeaders(HttpHeaders headers)
Description copied from interface:HttpMetaDataClears the current header entries and copies all header entries of the specifiedheadersobject.- Specified by:
setHeadersin interfaceHttpMetaData- Specified by:
setHeadersin interfaceHttpRequestMetaData- Parameters:
headers- the headers object which contains new values.- Returns:
this.
-
addCookie
default StreamingHttpRequest addCookie(HttpCookiePair cookie)
Description copied from interface:HttpMetaDataAdds a cookie.This may result in multiple
HttpCookiePairs with same name.- Specified by:
addCookiein interfaceHttpMetaData- Specified by:
addCookiein interfaceHttpRequestMetaData- Parameters:
cookie- the cookie to add.- Returns:
this.
-
addCookie
default StreamingHttpRequest addCookie(java.lang.CharSequence name, java.lang.CharSequence value)
Description copied from interface:HttpMetaDataAdds 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.- Specified by:
addCookiein interfaceHttpMetaData- Specified by:
addCookiein interfaceHttpRequestMetaData- Parameters:
name- the name of the cookie.value- the value of the cookie.- Returns:
this.
-
addSetCookie
default StreamingHttpRequest addSetCookie(HttpSetCookie cookie)
Description copied from interface:HttpMetaDataAdds a set-cookie.This may result in multiple
HttpSetCookies with same name.- Specified by:
addSetCookiein interfaceHttpMetaData- Specified by:
addSetCookiein interfaceHttpRequestMetaData- Parameters:
cookie- the cookie to add.- Returns:
this.
-
addSetCookie
default StreamingHttpRequest addSetCookie(java.lang.CharSequence name, java.lang.CharSequence value)
Description copied from interface:HttpMetaDataAdds 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.- Specified by:
addSetCookiein interfaceHttpMetaData- Specified by:
addSetCookiein interfaceHttpRequestMetaData- Parameters:
name- the name of the cookie.value- the value of the cookie.- Returns:
this.
-
-