Interface BlockingStreamingHttpRequest
-
- All Superinterfaces:
HttpMetaData
,HttpRequestMetaData
public interface BlockingStreamingHttpRequest extends HttpRequestMetaData
The equivalent ofHttpRequest
but provides the payload as aBlockingIterable
.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default BlockingStreamingHttpRequest
addCookie(HttpCookiePair cookie)
Adds a cookie.default BlockingStreamingHttpRequest
addCookie(java.lang.CharSequence name, java.lang.CharSequence value)
default BlockingStreamingHttpRequest
addHeader(java.lang.CharSequence name, java.lang.CharSequence value)
Adds a new header with the specifiedname
andvalue
.default BlockingStreamingHttpRequest
addHeaders(HttpHeaders headers)
Adds all header names and values ofheaders
object.BlockingStreamingHttpRequest
addQueryParameter(java.lang.String key, java.lang.String value)
Adds a new query parameter with the specifiedkey
andvalue
, which will be percent-encoded if needed.BlockingStreamingHttpRequest
addQueryParameters(java.lang.String key, java.lang.Iterable<java.lang.String> values)
Adds new query parameters with the specifiedkey
andvalues
.BlockingStreamingHttpRequest
addQueryParameters(java.lang.String key, java.lang.String... values)
Adds new query parameters with the specifiedkey
andvalues
.default BlockingStreamingHttpRequest
addSetCookie(HttpSetCookie cookie)
Adds a set-cookie.default BlockingStreamingHttpRequest
addSetCookie(java.lang.CharSequence name, java.lang.CharSequence value)
BlockingStreamingHttpRequest
appendPathSegments(java.lang.String... segments)
Appends segments to the currentHttpRequestMetaData.path()
, performing encoding of each segment (including ('/'
) characters) according to percent-encoding.BlockingStreamingHttpRequest
encoding(ContentCodec encoding)
TheContentCodec
used to encode the payload of a request or a response.BlockingStreamingHttpRequest
method(HttpRequestMethod method)
Set theHttpRequestMethod
of thisStreamingHttpRequest
.BlockingStreamingHttpRequest
path(java.lang.String path)
Sets the path, performing encoding according to percent-encoding, except for forward-slash ('/'
) characters.BlockingIterable<Buffer>
payloadBody()
BlockingStreamingHttpRequest
payloadBody(CloseableIterable<Buffer> payloadBody)
Returns aBlockingStreamingHttpRequest
with its underlying payload set topayloadBody
.<T> BlockingStreamingHttpRequest
payloadBody(CloseableIterable<T> payloadBody, HttpSerializer<T> serializer)
Returns aBlockingStreamingHttpRequest
with its underlying payload set to the result of serialization.default <T> BlockingIterable<T>
payloadBody(HttpDeserializer<T> deserializer)
Gets and deserializes the payload body.BlockingStreamingHttpRequest
payloadBody(java.io.InputStream payloadBody)
Returns aBlockingStreamingHttpRequest
with its underlying payload set topayloadBody
.BlockingStreamingHttpRequest
payloadBody(java.lang.Iterable<Buffer> payloadBody)
Returns aBlockingStreamingHttpRequest
with its underlying payload set topayloadBody
.<T> BlockingStreamingHttpRequest
payloadBody(java.lang.Iterable<T> payloadBody, HttpSerializer<T> serializer)
Returns aBlockingStreamingHttpRequest
with its underlying payload set to the result of serialization.default java.io.InputStream
payloadBodyInputStream()
Gets the underlying payload as aInputStream
.BlockingStreamingHttpRequest
query(java.lang.String query)
Sets the path, performing encoding according to rfc3986, Query.BlockingStreamingHttpRequest
rawPath(java.lang.String path)
Sets the path topath
, without any encoding performed.BlockingStreamingHttpRequest
rawQuery(java.lang.String query)
Sets the query component toquery
, without any encoding performed.BlockingStreamingHttpRequest
requestTarget(java.lang.String requestTarget)
Set the request-target.BlockingStreamingHttpRequest
requestTarget(java.lang.String requestTarget, java.nio.charset.Charset encoding)
Set the request-target.default BlockingStreamingHttpRequest
setHeader(java.lang.CharSequence name, java.lang.CharSequence value)
Sets a header with the specifiedname
andvalue
.default BlockingStreamingHttpRequest
setHeaders(HttpHeaders headers)
Clears the current header entries and copies all header entries of the specifiedheaders
object.BlockingStreamingHttpRequest
setQueryParameter(java.lang.String key, java.lang.String value)
BlockingStreamingHttpRequest
setQueryParameters(java.lang.String key, java.lang.Iterable<java.lang.String> values)
Sets new query parameters with the specifiedkey
andvalues
.BlockingStreamingHttpRequest
setQueryParameters(java.lang.String key, java.lang.String... values)
Sets new query parameters with the specifiedkey
andvalues
.Single<HttpRequest>
toRequest()
Translates thisBlockingStreamingHttpRequest
to aHttpRequest
.StreamingHttpRequest
toStreamingRequest()
Translates thisBlockingStreamingHttpRequest
to aStreamingHttpRequest
.<T> BlockingStreamingHttpRequest
transform(TrailersTransformer<T,Buffer> trailersTransformer)
Returns aBlockingStreamingHttpRequest
with its underlying payload transformed toBuffer
s, with access to the trailers.<T> BlockingStreamingHttpRequest
transformPayloadBody(java.util.function.Function<BlockingIterable<Buffer>,BlockingIterable<T>> transformer, HttpSerializer<T> serializer)
Returns aBlockingStreamingHttpRequest
with its underlying payload transformed to the result of serialization.default <T,R>
BlockingStreamingHttpRequesttransformPayloadBody(java.util.function.Function<BlockingIterable<T>,BlockingIterable<R>> transformer, HttpDeserializer<T> deserializer, HttpSerializer<R> serializer)
Returns aBlockingStreamingHttpRequest
with its underlying payload transformed to the result of serialization.BlockingStreamingHttpRequest
transformPayloadBody(java.util.function.UnaryOperator<BlockingIterable<Buffer>> transformer)
Returns aBlockingStreamingHttpRequest
with its underlying payload transformed toBuffer
s.BlockingStreamingHttpRequest
version(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
BlockingIterable<Buffer> payloadBody()
-
payloadBodyInputStream
default java.io.InputStream payloadBodyInputStream()
Gets the underlying payload as aInputStream
.- Returns:
- The
InputStream
representation of the underlying payload body.
-
payloadBody
default <T> BlockingIterable<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 underlyingBlockingIterable
.- Returns:
- The results of the deserialization operation.
-
payloadBody
BlockingStreamingHttpRequest payloadBody(java.lang.Iterable<Buffer> payloadBody)
Returns aBlockingStreamingHttpRequest
with its underlying payload set topayloadBody
.A best effort will be made to apply back pressure to the existing payload body which is being replaced. If this default policy is not sufficient you can use
transformPayloadBody(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 existing payload body that is being replaced.- Parameters:
payloadBody
- The new payload body.- Returns:
this
-
payloadBody
BlockingStreamingHttpRequest payloadBody(CloseableIterable<Buffer> payloadBody)
Returns aBlockingStreamingHttpRequest
with its underlying payload set topayloadBody
.A best effort will be made to apply back pressure to the existing payload body which is being replaced. If this default policy is not sufficient you can use
transformPayloadBody(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 existing payload body that is being replaced.- Parameters:
payloadBody
- The new payload body.- Returns:
this
-
payloadBody
BlockingStreamingHttpRequest payloadBody(java.io.InputStream payloadBody)
Returns aBlockingStreamingHttpRequest
with its underlying payload set topayloadBody
.A best effort will be made to apply back pressure to the existing payload body which is being replaced. If this default policy is not sufficient you can use
transformPayloadBody(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 existing payload body that is being replaced.- Parameters:
payloadBody
- The new payload body.- Returns:
this
-
payloadBody
<T> BlockingStreamingHttpRequest payloadBody(java.lang.Iterable<T> payloadBody, HttpSerializer<T> serializer)
Returns aBlockingStreamingHttpRequest
with its underlying payload set to the result of serialization.A best effort will be made to apply back pressure to the existing payload body which is being replaced. If this default policy is not sufficient you can use
transformPayloadBody(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 existing payload body that is being replaced.- 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
-
payloadBody
<T> BlockingStreamingHttpRequest payloadBody(CloseableIterable<T> payloadBody, HttpSerializer<T> serializer)
Returns aBlockingStreamingHttpRequest
with its underlying payload set to the result of serialization.A best effort will be made to apply back pressure to the existing payload body which is being replaced. If this default policy is not sufficient you can use
transformPayloadBody(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 existing payload body that is being replaced.- 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> BlockingStreamingHttpRequest transformPayloadBody(java.util.function.Function<BlockingIterable<Buffer>,BlockingIterable<T>> transformer, HttpSerializer<T> serializer)
Returns aBlockingStreamingHttpRequest
with its underlying payload transformed to the result of serialization.- Type Parameters:
T
- The type of objects to serialize.- Parameters:
transformer
- AFunction
which take as a parameter the existing payload bodyBlockingIterable
and returns the new payload bodyBlockingIterable
prior to serialization. It is assumed the existing payload bodyBlockingIterable
will be transformed/consumed or else no more requests may be processed.serializer
- Used to serialize the payload body.- Returns:
this
-
transformPayloadBody
default <T,R> BlockingStreamingHttpRequest transformPayloadBody(java.util.function.Function<BlockingIterable<T>,BlockingIterable<R>> transformer, HttpDeserializer<T> deserializer, HttpSerializer<R> serializer)
Returns aBlockingStreamingHttpRequest
with 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
- AFunction
which take as a parameter the existing payload bodyBlockingIterable
and returns the new payload bodyBlockingIterable
prior to serialization. It is assumed the existing payload bodyBlockingIterable
will 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
BlockingStreamingHttpRequest transformPayloadBody(java.util.function.UnaryOperator<BlockingIterable<Buffer>> transformer)
Returns aBlockingStreamingHttpRequest
with its underlying payload transformed toBuffer
s.- Parameters:
transformer
- AFunction
which take as a parameter the existing payload bodyBlockingIterable
and returns the new payload bodyBlockingIterable
. It is assumed the existing payload bodyBlockingIterable
will be transformed/consumed or else no more requests may be processed.- Returns:
this
-
transform
<T> BlockingStreamingHttpRequest transform(TrailersTransformer<T,Buffer> trailersTransformer)
Returns aBlockingStreamingHttpRequest
with its underlying payload transformed toBuffer
s, with access to the trailers.- Type Parameters:
T
- The type of state used during the transformation.- Parameters:
trailersTransformer
-TrailersTransformer
to use for this transform.- Returns:
this
-
toRequest
Single<HttpRequest> toRequest()
Translates thisBlockingStreamingHttpRequest
to aHttpRequest
.- Returns:
- a
Single
that completes with aHttpRequest
representation of thisBlockingStreamingHttpRequest
.
-
toStreamingRequest
StreamingHttpRequest toStreamingRequest()
Translates thisBlockingStreamingHttpRequest
to aStreamingHttpRequest
.- Returns:
- a
StreamingHttpRequest
representation of thisBlockingStreamingHttpRequest
.
-
rawPath
BlockingStreamingHttpRequest rawPath(java.lang.String path)
Description copied from interface:HttpRequestMetaData
Sets 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:
rawPath
in interfaceHttpRequestMetaData
- Parameters:
path
- the encoded path to set.- Returns:
this
.
-
path
BlockingStreamingHttpRequest path(java.lang.String path)
Description copied from interface:HttpRequestMetaData
Sets the path, performing encoding according to percent-encoding, except for forward-slash ('/'
) characters. This allows forpath("/abc")
without it turning into'%2Fabc'
.- Specified by:
path
in interfaceHttpRequestMetaData
- Parameters:
path
- the un-encoded path to set.- Returns:
this
.
-
appendPathSegments
BlockingStreamingHttpRequest appendPathSegments(java.lang.String... segments)
Description copied from interface:HttpRequestMetaData
Appends 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:
appendPathSegments
in interfaceHttpRequestMetaData
- Parameters:
segments
- the un-encoded path to set.- Returns:
this
.
-
rawQuery
BlockingStreamingHttpRequest rawQuery(@Nullable java.lang.String query)
Description copied from interface:HttpRequestMetaData
Sets 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:
rawQuery
in interfaceHttpRequestMetaData
- Parameters:
query
- the encoded query to set.null
will clear the query value (e.g. no?
present inHttpRequestMetaData.requestTarget()
.- Returns:
this
.
-
query
BlockingStreamingHttpRequest query(@Nullable java.lang.String query)
Description copied from interface:HttpRequestMetaData
Sets the path, performing encoding according to rfc3986, Query.- Specified by:
query
in interfaceHttpRequestMetaData
- Parameters:
query
- the un-encoded query to set.null
will clear the query value (e.g. no?
present inHttpRequestMetaData.requestTarget()
.- Returns:
this
.
-
addQueryParameter
BlockingStreamingHttpRequest addQueryParameter(java.lang.String key, java.lang.String value)
Description copied from interface:HttpRequestMetaData
Adds a new query parameter with the specifiedkey
andvalue
, which will be percent-encoded if needed.- Specified by:
addQueryParameter
in interfaceHttpRequestMetaData
- Parameters:
key
- the query parameter key.value
- the query parameter value.- Returns:
this
.
-
addQueryParameters
BlockingStreamingHttpRequest addQueryParameters(java.lang.String key, java.lang.Iterable<java.lang.String> values)
Description copied from interface:HttpRequestMetaData
Adds new query parameters with the specifiedkey
andvalues
. This method is semantically equivalent to:for (T value : values) { addQueryParameter(key, value); }
- Specified by:
addQueryParameters
in interfaceHttpRequestMetaData
- Parameters:
key
- the query parameter key.values
- the query parameter values.- Returns:
this
.
-
addQueryParameters
BlockingStreamingHttpRequest addQueryParameters(java.lang.String key, java.lang.String... values)
Description copied from interface:HttpRequestMetaData
Adds new query parameters with the specifiedkey
andvalues
. This method is semantically equivalent to:for (T value : values) { query.addQueryParameter(key, value); }
- Specified by:
addQueryParameters
in interfaceHttpRequestMetaData
- Parameters:
key
- the query parameter key.values
- the query parameter values.- Returns:
this
.
-
setQueryParameter
BlockingStreamingHttpRequest setQueryParameter(java.lang.String key, java.lang.String value)
Description copied from interface:HttpRequestMetaData
Sets a query parameter with the specifiedkey
andvalue
, which will be percent-encoded if needed. Any existing query parameters with the same key are overwritten.- Specified by:
setQueryParameter
in interfaceHttpRequestMetaData
- Parameters:
key
- the query parameter key.value
- the query parameter value.- Returns:
this
.
-
setQueryParameters
BlockingStreamingHttpRequest setQueryParameters(java.lang.String key, java.lang.Iterable<java.lang.String> values)
Description copied from interface:HttpRequestMetaData
Sets new query parameters with the specifiedkey
andvalues
. This method is equivalent to:removeQueryParameter(key); for (T value : values) { query.addQueryParameter(key, value); }
- Specified by:
setQueryParameters
in interfaceHttpRequestMetaData
- Parameters:
key
- the query parameter key.values
- the query parameter values.- Returns:
this
.
-
setQueryParameters
BlockingStreamingHttpRequest setQueryParameters(java.lang.String key, java.lang.String... values)
Description copied from interface:HttpRequestMetaData
Sets new query parameters with the specifiedkey
andvalues
. This method is equivalent to:removeQueryParameter(key); for (T value : values) { query.addQueryParameter(key, value); }
- Specified by:
setQueryParameters
in interfaceHttpRequestMetaData
- Parameters:
key
- the query parameter key.values
- the query parameter values.- Returns:
this
.
-
version
BlockingStreamingHttpRequest version(HttpProtocolVersion version)
Description copied from interface:HttpMetaData
Set the protocol version of thisHttpMetaData
.- Specified by:
version
in interfaceHttpMetaData
- Specified by:
version
in interfaceHttpRequestMetaData
- Parameters:
version
- the protocol version to set.- Returns:
this
.
-
encoding
BlockingStreamingHttpRequest encoding(ContentCodec encoding)
Description copied from interface:HttpMetaData
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()
.- Specified by:
encoding
in interfaceHttpMetaData
- Parameters:
encoding
- TheContentCodec
used for the encoding of the payload.- Returns:
this
.- See Also:
- Content-Encoding
-
method
BlockingStreamingHttpRequest method(HttpRequestMethod method)
Description copied from interface:HttpRequestMetaData
Set theHttpRequestMethod
of thisStreamingHttpRequest
.- Specified by:
method
in interfaceHttpRequestMetaData
- Parameters:
method
- theHttpRequestMethod
to set.- Returns:
this
.
-
requestTarget
BlockingStreamingHttpRequest requestTarget(java.lang.String requestTarget)
Description copied from interface:HttpRequestMetaData
Set 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:
requestTarget
in interfaceHttpRequestMetaData
- Parameters:
requestTarget
- the percent-encoded request-target to set.- Returns:
this
.
-
requestTarget
BlockingStreamingHttpRequest requestTarget(java.lang.String requestTarget, java.nio.charset.Charset encoding)
Description copied from interface:HttpRequestMetaData
Set 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:
requestTarget
in interfaceHttpRequestMetaData
- Parameters:
requestTarget
- the request-target to set.encoding
- theCharset
to use to encoderequestTarget
before setting the value.- Returns:
this
.
-
addHeader
default BlockingStreamingHttpRequest addHeader(java.lang.CharSequence name, java.lang.CharSequence value)
Description copied from interface:HttpMetaData
Adds a new header with the specifiedname
andvalue
.- Specified by:
addHeader
in interfaceHttpMetaData
- Specified by:
addHeader
in interfaceHttpRequestMetaData
- Parameters:
name
- the name of the header.value
- the value of the header.- Returns:
this
.
-
addHeaders
default BlockingStreamingHttpRequest addHeaders(HttpHeaders headers)
Description copied from interface:HttpMetaData
Adds all header names and values ofheaders
object.- Specified by:
addHeaders
in interfaceHttpMetaData
- Specified by:
addHeaders
in interfaceHttpRequestMetaData
- Parameters:
headers
- the headers to add.- Returns:
this
.
-
setHeader
default BlockingStreamingHttpRequest setHeader(java.lang.CharSequence name, java.lang.CharSequence value)
Description copied from interface:HttpMetaData
Sets a header with the specifiedname
andvalue
. Any existing headers with the same name are overwritten.- Specified by:
setHeader
in interfaceHttpMetaData
- Specified by:
setHeader
in interfaceHttpRequestMetaData
- Parameters:
name
- the name of the header.value
- the value of the header.- Returns:
this
.
-
setHeaders
default BlockingStreamingHttpRequest setHeaders(HttpHeaders headers)
Description copied from interface:HttpMetaData
Clears the current header entries and copies all header entries of the specifiedheaders
object.- Specified by:
setHeaders
in interfaceHttpMetaData
- Specified by:
setHeaders
in interfaceHttpRequestMetaData
- Parameters:
headers
- the headers object which contains new values.- Returns:
this
.
-
addCookie
default BlockingStreamingHttpRequest addCookie(HttpCookiePair cookie)
Description copied from interface:HttpMetaData
Adds a cookie.This may result in multiple
HttpCookiePair
s with same name.- Specified by:
addCookie
in interfaceHttpMetaData
- Specified by:
addCookie
in interfaceHttpRequestMetaData
- Parameters:
cookie
- the cookie to add.- Returns:
this
.
-
addCookie
default BlockingStreamingHttpRequest addCookie(java.lang.CharSequence name, java.lang.CharSequence value)
Description copied from interface:HttpMetaData
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.- Specified by:
addCookie
in interfaceHttpMetaData
- Specified by:
addCookie
in interfaceHttpRequestMetaData
- Parameters:
name
- the name of the cookie.value
- the value of the cookie.- Returns:
this
.
-
addSetCookie
default BlockingStreamingHttpRequest addSetCookie(HttpSetCookie cookie)
Description copied from interface:HttpMetaData
Adds a set-cookie.This may result in multiple
HttpSetCookie
s with same name.- Specified by:
addSetCookie
in interfaceHttpMetaData
- Specified by:
addSetCookie
in interfaceHttpRequestMetaData
- Parameters:
cookie
- the cookie to add.- Returns:
this
.
-
addSetCookie
default BlockingStreamingHttpRequest addSetCookie(java.lang.CharSequence name, java.lang.CharSequence value)
Description copied from interface:HttpMetaData
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.- Specified by:
addSetCookie
in interfaceHttpMetaData
- Specified by:
addSetCookie
in interfaceHttpRequestMetaData
- Parameters:
name
- the name of the cookie.value
- the value of the cookie.- Returns:
this
.
-
-