A PushBuilder is obtained by calling Request#newPushBuilder(). Each call to this method will return a new
instance of a PushBuilder based off the current HttpServletRequest. Any mutations to the returned PushBuilder are not reflected on future returns.
The instance is initialized as follows:
Request are added to the builder, except for:
Request#getRequestedSessionId() value, unless at the time of the call
Request#getSession(boolean) has previously been called to create a new Session, in which case the new
session ID will be used as the PushBuilder's requested session ID. The source of the requested session id will be the
same as for the requestRequest#getRequestURL() plus any Request#getQueryString()
Response#addCookie(Cookie) has been called on the associated response, then a corresponding Cookie
header will be added to the PushBuilder, unless the Cookie#getMaxAge() is <=0, in which case the Cookie
will be removed from the builder.
The path 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 path and conditional headers are cleared before returning from
push. All other values are retained over calls to push().
| Modifier and Type | Field and Description |
|---|---|
| private static final Header[] | |
| pack-priv List | |
| pack-priv MimeHeaders | |
| pack-priv String | |
| pack-priv String | |
| pack-priv String | |
| private static final Header[] | |
| pack-priv Request | |
| pack-priv boolean | |
| pack-priv String |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public PushBuilder | |
| public PushBuilder | |
| private String | |
| public String | |
| public Iterable | Returns: the set of header to be used for the push.Return the set of header to be used for the push. |
| public String | |
| public String | |
| public String | Returns: the query string to be used for the push.Return the query string to be used for the push. |
| public String | Returns: the SessionID to be used for the push.Return the SessionID to be used for the push. |
| public PushBuilder | |
| private static boolean | |
| public PushBuilder | |
| public void | |
| public PushBuilder | Returns: this builder.the query string to be used for the push. queryString)Set the query string to be used for the push. |
| public PushBuilder | Returns: this builder.The name of the header to remove name)Remove the named request header. |
| public PushBuilder | Returns: this builder.The name)Header to removeRemove the named request header. |
| public PushBuilder | |
| public PushBuilder | |
| public PushBuilder | |
| private static String | |
| private static boolean |
| CONDITIONAL_HEADERS | back to summary |
|---|---|
| private static final Header[] CONDITIONAL_HEADERS | |
| cookies | back to summary |
|---|---|
| pack-priv List<Cookie> cookies | |
| headers | back to summary |
|---|---|
| pack-priv MimeHeaders headers | |
| method | back to summary |
|---|---|
| pack-priv String method | |
| path | back to summary |
|---|---|
| pack-priv String path | |
| queryString | back to summary |
|---|---|
| pack-priv String queryString | |
| REMOVE_HEADERS | back to summary |
|---|---|
| private static final Header[] REMOVE_HEADERS | |
| request | back to summary |
|---|---|
| pack-priv Request request | |
| sessionFromURL | back to summary |
|---|---|
| pack-priv boolean sessionFromURL | |
| sessionId | back to summary |
|---|---|
| pack-priv String sessionId | |
| PushBuilder | back to summary |
|---|---|
| public PushBuilder(final Request request) | |
| addHeader | back to summary |
|---|---|
| public PushBuilder addHeader(String name, String value) Add a request header to be used for the push.
| |
| addHeader | back to summary |
|---|---|
| public PushBuilder addHeader(Header name, String value) Add a request header to be used for the push.
| |
| composeReferrerHeader | back to summary |
|---|---|
| private String composeReferrerHeader(final Request request) | |
| getHeader | back to summary |
|---|---|
| public String getHeader(String name) Return the header of the given name to be used for the push.
| |
| getHeaderNames | back to summary |
|---|---|
| public Iterable Return the set of header to be used for the push. | |
| getMethod | back to summary |
|---|---|
| public String getMethod() Return the method to be used for the push.
| |
| getPath | back to summary |
|---|---|
| public String getPath() Return the URI path to be used for the push.
| |
| getQueryString | back to summary |
|---|---|
| public String getQueryString() Return the query string to be used for the push.
| |
| getSessionId | back to summary |
|---|---|
| public String getSessionId() Return the SessionID to be used for the push.
| |
| method | back to summary |
|---|---|
| public PushBuilder method(final String method) Set the method to be used for the push.
| |
| nameAndValueValid | back to summary |
|---|---|
| private static boolean nameAndValueValid(final String name, final String value) | |
| path | back to summary |
|---|---|
| public PushBuilder path(String path) 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 | back to summary |
|---|---|
| public void push() Push a resource given the current state of the builder without 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. Before returning from this method, the builder has its path set to null and all conditional headers removed. All other fields are left as is for possible reuse in another push.
| |
| queryString | back to summary |
|---|---|
| public PushBuilder queryString(String queryString) Set the query string to be used for the push.
Will be appended to any query String included in a call to
| |
| removeHeader | back to summary |
|---|---|
| public PushBuilder removeHeader(String name) Remove the named request header. If the header does not exist, take no action.
| |
| removeHeader | back to summary |
|---|---|
| public PushBuilder removeHeader(Header name) Remove the named request header. If the header does not exist, take no action.
| |
| sessionId | back to summary |
|---|---|
| public PushBuilder sessionId(String sessionId) 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.
| |
| setHeader | back to summary |
|---|---|
| public PushBuilder setHeader(String name, String value) 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.
| |
| setHeader | back to summary |
|---|---|
| public PushBuilder setHeader(Header name, String value) 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.
| |
| validate | back to summary |
|---|---|
| private static String validate(final String value) | |
| validValue | back to summary |
|---|---|
| private static boolean validValue(final String value) | |