Interface HttpRequestMetaData

All Superinterfaces:
ContextMapHolder, HttpMetaData
All Known Subinterfaces:
BlockingStreamingHttpRequest, HttpRequest, StreamingHttpRequest

public interface HttpRequestMetaData extends HttpMetaData
Meta data associated with an HTTP request.
  • Method Details

    • method

      Returns:
      The HttpRequestMethod of this StreamingHttpRequest
    • method

      Parameters:
      method - the HttpRequestMethod to set.
      Returns:
      this.
    • requestTarget

      String requestTarget()
      The request-target.

      No decoding has been done on the request-target.

      Returns:
      The request-target.

      No decoding has been done on the request-target.

    • requestTarget

      String requestTarget(Charset encoding)
      Parameters:
      encoding - the Charset to use to decode the request-target.
      Returns:
      The request-target.
    • requestTarget

      HttpRequestMetaData requestTarget(String requestTarget)
      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 as path(), rawQuery(), etc.

      Parameters:
      requestTarget - the percent-encoded request-target to set.
      Returns:
      this.
    • requestTarget

      HttpRequestMetaData requestTarget(String requestTarget, Charset encoding)
      Set the request-target.

      This may result in clearing of internal caches used by methods that are derived from the request-target, such as path(), rawQuery(), etc.

      Parameters:
      requestTarget - the request-target to set.
      encoding - the Charset to use to encode requestTarget before setting the value.
      Returns:
      this.
    • scheme

      @Nullable String scheme()
      The scheme component derived from requestTarget() in lower case.
      Returns:
      The scheme component derived from requestTarget() in lower case, or null if none can be derived.
    • userInfo

      @Nullable String userInfo()
      Returns:
      The user information component derived from requestTarget(), or null if none can be derived.
    • host

      @Nullable String host()
      Returns:
      The host component derived from requestTarget(), or null if none can be derived.
    • port

      int port()
      Returns:
      The port component derived from requestTarget(), or <0 if none can be derived.
    • rawPath

      String rawPath()
      The path component derived from requestTarget().

      No decoding has been done on the query component: the value is provided as specified in the request target.

      Returns:
      The path component derived from requestTarget().

      No decoding has been done on the query component: the value is provided as specified in the request target.

    • path

      String path()
      Get an equivalent value as rawPath() but decoded according to percent-encoding.
      Returns:
      an equivalent value as rawPath() but decoded according to percent-encoding.
    • rawPath

      HttpRequestMetaData rawPath(String path)
      Sets the path to path, 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 requestTarget(String).

      Parameters:
      path - the encoded path to set.
      Returns:
      this.
    • path

      Sets the path, performing encoding according to percent-encoding, except for forward-slash ('/') characters. This allows for path("/abc") without it turning into '%2Fabc'.
      Parameters:
      path - the un-encoded path to set.
      Returns:
      this.
    • appendPathSegments

      HttpRequestMetaData appendPathSegments(String... segments)
      Appends segments to the current path(), performing encoding of each segment (including ('/') characters) according to percent-encoding. A / is used to separate each segment and between the current path() and the following segments.
      Parameters:
      segments - the un-encoded path to set.
      Returns:
      this.
    • rawQuery

      @Nullable String rawQuery()
      The query component derived from requestTarget().

      No decoding has been done on the query component: the value is provided as specified in the request target.

      Returns:
      The query component derived from requestTarget().

      No decoding has been done on the query component: the value is provided as specified in the request target.

    • query

      @Nullable String query()
      Get an equivalent value as rawQuery() but decoded according to rfc3986, Query.
      Returns:
      an equivalent value as rawQuery() but decoded according to rfc3986, Query.
    • rawQuery

      HttpRequestMetaData rawQuery(@Nullable String query)
      Sets the query component to query, 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 requestTarget(String).

      Parameters:
      query - the encoded query to set. null will clear the query value (e.g. no ? present in requestTarget().
      Returns:
      this.
    • query

      HttpRequestMetaData query(@Nullable String query)
      Sets the path, performing encoding according to rfc3986, Query.
      Parameters:
      query - the un-encoded query to set. null will clear the query value (e.g. no ? present in requestTarget().
      Returns:
      this.
    • queryParameter

      @Nullable String queryParameter(String key)
      Returns the value of a query parameter with the specified key. If there is more than one value for the specified key, the first value in insertion order is returned.
      Parameters:
      key - the key of the query parameter to retrieve.
      Returns:
      the first query parameter value if the key is found. null if there's no such key.
    • queryParameters

      Iterable<Map.Entry<String,String>> queryParameters()
      Returns all query parameters as key/value pairs.
      Returns:
      an Iterable of query parameter key/value pairs or an empty Iterable if none present.
    • queryParameters

      Iterable<String> queryParameters(String key)
      Returns all values for the query parameter with the specified key.
      Parameters:
      key - the key of the query parameter to retrieve.
      Returns:
      an Iterable of query parameter values or an empty Iterable if no values are found.
    • queryParametersIterator

      Iterator<String> queryParametersIterator(String key)
      Returns all values for the query parameter with the specified key.
      Parameters:
      key - the key of the query parameter to retrieve.
      Returns:
      an Iterator of query parameter values or an empty Iterator if no values are found.
    • queryParametersKeys

      Set<String> queryParametersKeys()
      Returns a Set of all query parameter keys. The returned Set cannot be modified.
      Returns:
      a Set of all query parameter keys. The returned Set cannot be modified.
    • hasQueryParameter

      default boolean hasQueryParameter(String key)
      Returns true if a query parameter with the key exists, false otherwise.
      Parameters:
      key - the query parameter name.
      Returns:
      true if key exists.
    • hasQueryParameter

      boolean hasQueryParameter(String key, @Nullable String value)
      Returns true if a query parameter with the key and value exists, false otherwise.
      Parameters:
      key - the query parameter key.
      value - the query parameter value of the query parameter to find.
      Returns:
      true if a key, value pair exists.
    • queryParametersSize

      int queryParametersSize()
      Returns the number of query parameters.
      Returns:
      the number of query parameters.
    • addQueryParameter

      HttpRequestMetaData addQueryParameter(String key, @Nullable String value)
      Adds a new query parameter with the specified key and value, which will be percent-encoded if needed.
      Parameters:
      key - the query parameter key.
      value - the query parameter value.
      Returns:
      this.
    • addQueryParameters

      HttpRequestMetaData addQueryParameters(String key, Iterable<String> values)
      Adds new query parameters with the specified key and values. This method is semantically equivalent to:
       for (T value : values) {
           addQueryParameter(key, value);
       }
       
      Parameters:
      key - the query parameter key.
      values - the query parameter values.
      Returns:
      this.
    • addQueryParameters

      HttpRequestMetaData addQueryParameters(String key, String... values)
      Adds new query parameters with the specified key and values. This method is semantically equivalent to:
       for (T value : values) {
           query.addQueryParameter(key, value);
       }
       
      Parameters:
      key - the query parameter key.
      values - the query parameter values.
      Returns:
      this.
    • setQueryParameter

      HttpRequestMetaData setQueryParameter(String key, @Nullable String value)
      Sets a query parameter with the specified key and value, which will be percent-encoded if needed. Any existing query parameters with the same key are overwritten.
      Parameters:
      key - the query parameter key.
      value - the query parameter value.
      Returns:
      this.
    • setQueryParameters

      HttpRequestMetaData setQueryParameters(String key, Iterable<String> values)
      Sets new query parameters with the specified key and values. This method is equivalent to:
       removeQueryParameter(key);
       for (T value : values) {
           query.addQueryParameter(key, value);
       }
       
      Parameters:
      key - the query parameter key.
      values - the query parameter values.
      Returns:
      this.
    • setQueryParameters

      HttpRequestMetaData setQueryParameters(String key, String... values)
      Sets new query parameters with the specified key and values. This method is equivalent to:
       removeQueryParameter(key);
       for (T value : values) {
           query.addQueryParameter(key, value);
       }
       
      Parameters:
      key - the query parameter key.
      values - the query parameter values.
      Returns:
      this.
    • removeQueryParameters

      boolean removeQueryParameters(String key)
      Removes all query parameters with the specified key.
      Parameters:
      key - the query parameter key.
      Returns:
      true if at least one entry has been removed.
    • removeQueryParameters

      boolean removeQueryParameters(String key, @Nullable String value)
      Removes all query parameters with the specified key and value.
      Parameters:
      key - the query parameter key.
      value - the query parameter value.
      Returns:
      true if at least one entry has been removed.
    • fragment

      @Nullable default String fragment()
      Returns the fragment part of the request target.
      Returns:
      the fragment part of the request target.
    • fragment

      default HttpRequestMetaData fragment(@Nullable String fragment)
      Sets the fragment part of the request target.
      Parameters:
      fragment - the fragment to set.
      Returns:
      this.
    • effectiveHostAndPort

      @Nullable HostAndPort effectiveHostAndPort()
      Get the host and port components of the effective request URI. The port component will be <0 if none can be derived. This method typically pulls information from requestTarget() and HttpHeaderNames.HOST header.
      Returns:
      The host and port components of the effective request URI. null if the request doesn't provide enough info to derive the host/port.
    • contentEncoding

      @Nullable BufferEncoder contentEncoding()
      Get the BufferEncoder to use for this request. The value can be used by filters (such as ContentEncodingHttpRequesterFilter) to apply HttpHeaderNames.CONTENT_ENCODING to the request.
      Returns:
      the BufferEncoder to use for this request.
    • contentEncoding

      HttpRequestMetaData contentEncoding(@Nullable BufferEncoder encoder)
      Set the BufferEncoder to use for this request. The value can be used by filters (such as ContentEncodingHttpRequesterFilter) to apply HttpHeaderNames.CONTENT_ENCODING to the request.
      Parameters:
      encoder - BufferEncoder to use for this request.
      Returns:
      this.
    • version

      Description copied from interface: HttpMetaData
      Set the protocol version of this HttpMetaData.
      Specified by:
      version in interface HttpMetaData
      Parameters:
      version - the protocol version to set.
      Returns:
      this.
    • addHeader

      default HttpRequestMetaData addHeader(CharSequence name, CharSequence value)
      Description copied from interface: HttpMetaData
      Adds a new header with the specified name and value.
      Specified by:
      addHeader in interface HttpMetaData
      Parameters:
      name - the name of the header.
      value - the value of the header.
      Returns:
      this.
    • addHeaders

      default HttpRequestMetaData addHeaders(HttpHeaders headers)
      Description copied from interface: HttpMetaData
      Adds all header names and values of headers object.
      Specified by:
      addHeaders in interface HttpMetaData
      Parameters:
      headers - the headers to add.
      Returns:
      this.
    • setHeader

      default HttpRequestMetaData setHeader(CharSequence name, CharSequence value)
      Description copied from interface: HttpMetaData
      Sets a header with the specified name and value. Any existing headers with the same name are overwritten.
      Specified by:
      setHeader in interface HttpMetaData
      Parameters:
      name - the name of the header.
      value - the value of the header.
      Returns:
      this.
    • setHeaders

      default HttpRequestMetaData setHeaders(HttpHeaders headers)
      Description copied from interface: HttpMetaData
      Clears the current header entries and copies all header entries of the specified headers object.
      Specified by:
      setHeaders in interface HttpMetaData
      Parameters:
      headers - the headers object which contains new values.
      Returns:
      this.
    • addCookie

      default HttpRequestMetaData addCookie(HttpCookiePair cookie)
      Description copied from interface: HttpMetaData
      Adds a cookie.

      This may result in multiple HttpCookiePairs with same name.

      Specified by:
      addCookie in interface HttpMetaData
      Parameters:
      cookie - the cookie to add.
      Returns:
      this.
    • addCookie

      default HttpRequestMetaData addCookie(CharSequence name, CharSequence value)
      Description copied from interface: HttpMetaData
      Adds a cookie with the specified name and value.

      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:
      addCookie in interface HttpMetaData
      Parameters:
      name - the name of the cookie.
      value - the value of the cookie.
      Returns:
      this.
    • addSetCookie

      default HttpRequestMetaData addSetCookie(HttpSetCookie cookie)
      Description copied from interface: HttpMetaData
      Adds a set-cookie.

      This may result in multiple HttpSetCookies with same name.

      Specified by:
      addSetCookie in interface HttpMetaData
      Parameters:
      cookie - the cookie to add.
      Returns:
      this.
    • addSetCookie

      default HttpRequestMetaData addSetCookie(CharSequence name, CharSequence value)
      Description copied from interface: HttpMetaData
      Adds a set-cookie with the specified name and value.

      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:
      addSetCookie in interface HttpMetaData
      Parameters:
      name - the name of the cookie.
      value - the value of the cookie.
      Returns:
      this.
    • context

      HttpRequestMetaData context(ContextMap context)
      Description copied from interface: HttpMetaData
      Sets a context for this HttpMetaData.

      Context can be used to associate a state with a request or response message without serializing its state on the wire.

      Specified by:
      context in interface ContextMapHolder
      Specified by:
      context in interface HttpMetaData
      Parameters:
      context - the new context for this HttpMetaData.
      Returns:
      this.