Interface HttpRequest
-
- All Superinterfaces:
HttpMetaData,HttpRequestMetaData
public interface HttpRequest extends HttpRequestMetaData
An HTTP request. The payload is represented as a singleObject.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default HttpRequestaddCookie(HttpCookiePair cookie)Adds a cookie.default HttpRequestaddCookie(java.lang.CharSequence name, java.lang.CharSequence value)default HttpRequestaddHeader(java.lang.CharSequence name, java.lang.CharSequence value)Adds a new header with the specifiednameandvalue.default HttpRequestaddHeaders(HttpHeaders headers)Adds all header names and values ofheadersobject.HttpRequestaddQueryParameter(java.lang.String key, java.lang.String value)Adds a new query parameter with the specifiedkeyandvalue, which will be percent-encoded if needed.HttpRequestaddQueryParameters(java.lang.String key, java.lang.Iterable<java.lang.String> values)Adds new query parameters with the specifiedkeyandvalues.HttpRequestaddQueryParameters(java.lang.String key, java.lang.String... values)Adds new query parameters with the specifiedkeyandvalues.default HttpRequestaddSetCookie(HttpSetCookie cookie)Adds a set-cookie.default HttpRequestaddSetCookie(java.lang.CharSequence name, java.lang.CharSequence value)default HttpRequestaddTrailer(java.lang.CharSequence name, java.lang.CharSequence value)default HttpRequestaddTrailers(HttpHeaders trailers)HttpRequestappendPathSegments(java.lang.String... segments)Appends segments to the currentHttpRequestMetaData.path(), performing encoding of each segment (including ('/') characters) according to percent-encoding.HttpRequestencoding(ContentCodec encoding)TheContentCodecused to encode the payload of a request or a response.HttpRequestmethod(HttpRequestMethod method)Set theHttpRequestMethodof thisStreamingHttpRequest.HttpRequestpath(java.lang.String path)Sets the path, performing encoding according to percent-encoding, except for forward-slash ('/') characters.BufferpayloadBody()Gets the underlying payload as aBuffer.HttpRequestpayloadBody(Buffer payloadBody)Returns anHttpRequestwith its underlying payload set topayloadBody.default <T> TpayloadBody(HttpDeserializer<T> deserializer)Gets and deserializes the payload body.<T> HttpRequestpayloadBody(T pojo, HttpSerializer<T> serializer)Returns anHttpRequestwith its underlying payload set to the results of serialization ofpojo.HttpRequestquery(java.lang.String query)Sets the path, performing encoding according to rfc3986, Query.HttpRequestrawPath(java.lang.String path)Sets the path topath, without any encoding performed.HttpRequestrawQuery(java.lang.String query)Sets the query component toquery, without any encoding performed.HttpRequestrequestTarget(java.lang.String requestTarget)Set the request-target.HttpRequestrequestTarget(java.lang.String requestTarget, java.nio.charset.Charset encoding)Set the request-target.default HttpRequestsetHeader(java.lang.CharSequence name, java.lang.CharSequence value)Sets a header with the specifiednameandvalue.default HttpRequestsetHeaders(HttpHeaders headers)Clears the current header entries and copies all header entries of the specifiedheadersobject.HttpRequestsetQueryParameter(java.lang.String key, java.lang.String value)HttpRequestsetQueryParameters(java.lang.String key, java.lang.Iterable<java.lang.String> values)Sets new query parameters with the specifiedkeyandvalues.HttpRequestsetQueryParameters(java.lang.String key, java.lang.String... values)Sets new query parameters with the specifiedkeyandvalues.default HttpRequestsetTrailer(java.lang.CharSequence name, java.lang.CharSequence value)default HttpRequestsetTrailers(HttpHeaders trailers)BlockingStreamingHttpRequesttoBlockingStreamingRequest()Translates thisHttpRequestto aBlockingStreamingHttpRequest.StreamingHttpRequesttoStreamingRequest()Translates thisHttpRequestto aStreamingHttpRequest.HttpHeaderstrailers()Gets the trailers.HttpRequestversion(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
Buffer payloadBody()
Gets the underlying payload as aBuffer.- Returns:
- The
Bufferrepresentation of the underlying payload.
-
payloadBody
default <T> 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 underlyingObject.- Returns:
- The results of the deserialization operation.
-
payloadBody
HttpRequest payloadBody(Buffer payloadBody)
Returns anHttpRequestwith its underlying payload set topayloadBody.- Parameters:
payloadBody- the underlying payload.- Returns:
this
-
payloadBody
<T> HttpRequest payloadBody(T pojo, HttpSerializer<T> serializer)
Returns anHttpRequestwith its underlying payload set to the results of serialization ofpojo.- Type Parameters:
T- The type of object to serialize.- Parameters:
pojo- The object to serialize.serializer- TheHttpSerializerwhich convertspojointo bytes.- Returns:
this
-
toStreamingRequest
StreamingHttpRequest toStreamingRequest()
Translates thisHttpRequestto aStreamingHttpRequest.- Returns:
- a
StreamingHttpRequestrepresentation of thisHttpRequest.
-
toBlockingStreamingRequest
BlockingStreamingHttpRequest toBlockingStreamingRequest()
Translates thisHttpRequestto aBlockingStreamingHttpRequest.- Returns:
- a
BlockingStreamingHttpRequestrepresentation of thisHttpRequest.
-
rawPath
HttpRequest 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
HttpRequest 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
HttpRequest 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
HttpRequest 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
HttpRequest 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
HttpRequest 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
HttpRequest 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
HttpRequest 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
HttpRequest 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
HttpRequest 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
HttpRequest 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
HttpRequest 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.
-
encoding
HttpRequest 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 passingIdentity.identity().- Specified by:
encodingin interfaceHttpMetaData- Parameters:
encoding- TheContentCodecused for the encoding of the payload.- Returns:
this.- See Also:
- Content-Encoding
-
method
HttpRequest method(HttpRequestMethod method)
Description copied from interface:HttpRequestMetaDataSet theHttpRequestMethodof thisStreamingHttpRequest.- Specified by:
methodin interfaceHttpRequestMetaData- Parameters:
method- theHttpRequestMethodto set.- Returns:
this.
-
requestTarget
HttpRequest 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
HttpRequest 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 HttpRequest 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 HttpRequest 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 HttpRequest 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 HttpRequest 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 HttpRequest 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 HttpRequest 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 HttpRequest 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 HttpRequest 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.
-
addTrailer
default HttpRequest addTrailer(java.lang.CharSequence name, java.lang.CharSequence value)
-
addTrailers
default HttpRequest addTrailers(HttpHeaders trailers)
-
setTrailer
default HttpRequest setTrailer(java.lang.CharSequence name, java.lang.CharSequence value)
-
setTrailers
default HttpRequest setTrailers(HttpHeaders trailers)
-
trailers
HttpHeaders trailers()
Gets the trailers.- Returns:
- the trailers.
-
-