Interface PushBuilder


@Deprecated public interface PushBuilder
Deprecated.
In favor of 103 early hints
Build a request to be pushed. According section 8.2 of RFC 7540, a promised request must be cacheable and safe without a request body.

A PushBuilder is obtained by calling HttpServletRequest.newPushBuilder(). Each call to this method will a new instance of a PushBuilder based off the current HttpServletRequest, or null. Any mutations to the returned PushBuilder are not reflected on future returns.

The instance is initialized as follows:

The path(java.lang.String) method must be called on the PushBuilder instance before the call to push(). Failure to do so must cause an exception to be thrown from push(), as specified in that method.

A PushBuilder can be customized by chained calls to mutator methods before the push() method is called to initiate an asynchronous push request with the current state of the builder. After the call to push(), the builder may be reused for another push, however the implementation must make it so the path(String) and conditional headers (defined in RFC 7232) values are cleared before returning from push(). All other values are retained over calls to push().

Since:
Servlet 4.0
  • Method Details

    • method

      PushBuilder method(String method)
      Deprecated.

      Set the method to be used for the push.

      Parameters:
      method - the method to be used for the push.
      Returns:
      this builder.
      Throws:
      NullPointerException - if the argument is null
      IllegalArgumentException - if the argument is the empty String, or any non-cacheable or unsafe methods defined in RFC 7231, which are POST, PUT, DELETE, CONNECT, OPTIONS and TRACE.
    • queryString

      PushBuilder queryString(String queryString)
      Deprecated.
      Set the query string to be used for the push. The query string will be appended to any query String included in a call to path(String). Any duplicate parameters must be preserved. This method should be used instead of a query in path(String) when multiple push() calls are to be made with the same query string.
      Parameters:
      queryString - the query string to be used for the push.
      Returns:
      this builder.
    • sessionId

      PushBuilder sessionId(String sessionId)
      Deprecated.
      Set the SessionID to be used for the push. The session ID will be set in the same way it was on the associated request (ie as a cookie if the associated request used a cookie, or as a url parameter if the associated request used a url parameter). Defaults to the requested session ID or any newly assigned session id from a newly created session.
      Parameters:
      sessionId - the SessionID to be used for the push.
      Returns:
      this builder.
    • setHeader

      PushBuilder setHeader(String name, String value)
      Deprecated.

      Set a request header to be used for the push. If the builder has an existing header with the same name, its value is overwritten.

      Parameters:
      name - The header name to set
      value - The header value to set
      Returns:
      this builder.
    • addHeader

      PushBuilder addHeader(String name, String value)
      Deprecated.

      Add a request header to be used for the push.

      Parameters:
      name - The header name to add
      value - The header value to add
      Returns:
      this builder.
    • removeHeader

      PushBuilder removeHeader(String name)
      Deprecated.

      Remove the named request header. If the header does not exist, take no action.

      Parameters:
      name - The name of the header to remove
      Returns:
      this builder.
    • path

      PushBuilder path(String path)
      Deprecated.
      Set the URI path to be used for the push. The path may start with "/" in which case it is treated as an absolute path, otherwise it is relative to the context path of the associated request. There is no path default and path(String) must be called before every call to push(). If a query string is present in the argument path, its contents must be merged with the contents previously passed to queryString(java.lang.String), preserving duplicates.
      Parameters:
      path - the URI path to be used for the push, which may include a query string.
      Returns:
      this builder.
    • push

      void push()
      Deprecated.
      Push a resource given the current state of the builder, the method must be non-blocking.

      Push a resource based on the current state of the PushBuilder. Calling this method does not guarantee the resource will actually be pushed, since it is possible the client can decline acceptance of the pushed resource using the underlying HTTP/2 protocol.

      If the builder has a session ID, then the pushed request will include the session ID either as a Cookie or as a URI parameter as appropriate. The builders query string is merged with any passed query string.

      Before returning from this method, the builder has its path, conditional headers (defined in RFC 7232) nulled. All other fields are left as is for possible reuse in another push.

      Throws:
      IllegalStateException - if there was no call to path(java.lang.String) on this instance either between its instantiation or the last call to push() that did not throw an IllegalStateException.
    • getMethod

      String getMethod()
      Deprecated.
      Return the method to be used for the push.
      Returns:
      the method to be used for the push.
    • getQueryString

      String getQueryString()
      Deprecated.
      Return the query string to be used for the push.
      Returns:
      the query string to be used for the push.
    • getSessionId

      String getSessionId()
      Deprecated.
      Return the SessionID to be used for the push.
      Returns:
      the SessionID to be used for the push.
    • getHeaderNames

      Set<String> getHeaderNames()
      Deprecated.
      Return the set of header to be used for the push.

      The returned set is not backed by the PushBuilder object, so changes in the returned set are not reflected in the PushBuilder object, and vice-versa.

      Returns:
      the set of header to be used for the push.
    • getHeader

      String getHeader(String name)
      Deprecated.
      Return the header of the given name to be used for the push.
      Parameters:
      name - the name of the header
      Returns:
      the header of the given name to be used for the push.
    • getPath

      String getPath()
      Deprecated.
      Return the URI path to be used for the push.
      Returns:
      the URI path to be used for the push.