public interface PushBuilder
A PushBuilder is obtained by calling Request.getPushBuilder()
which creates an initializes the builder as follows:
HttpServletRequest.getQueryString()
HttpServletRequest.getRequestedSessionId()
value, unless at the time
of the call HttpServletRequest.getSession(boolean)
has previously been called to create a new HttpSession
, in
which case the new session ID will be used as the PushBuilders
requested session ID. The source of the requested session id will be the
same as for the requestHttpServletRequest.getRequestURL()
plus any HttpServletRequest.getQueryString()
HttpServletResponse.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.isConditional()
header is set to true.A PushBuilder can be customized by chained calls to mutator methods before the
push()
method is called to initiate a 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(String)
, etag(String)
and
lastModified(String)
values will have been nulled. All other
values are retained over calls to push()
.
Modifier and Type | Method and Description |
---|---|
PushBuilder |
addHeader(String name,
String value)
Add a header to be used for the push.
|
PushBuilder |
conditional(boolean conditional)
Set if the request is to be conditional.
|
PushBuilder |
etag(String etag)
Set the etag to be used for conditional pushes.
|
String |
getEtag() |
String |
getHeader(String name) |
Set<String> |
getHeaderNames() |
String |
getLastModified() |
String |
getMethod() |
String |
getPath() |
String |
getQueryString() |
String |
getSessionId() |
boolean |
isConditional() |
PushBuilder |
lastModified(String lastModified)
Set the last modified date to be used for conditional pushes.
|
PushBuilder |
method(String method)
Set the method to be used for the push.
|
PushBuilder |
path(String path)
Set the URI path to be used for the push.
|
void |
push()
Push a resource.
|
PushBuilder |
queryString(String queryString)
Set the query string to be used for the push.
|
PushBuilder |
sessionId(String sessionId)
Set the SessionID to be used for the push.
|
PushBuilder |
setHeader(String name,
String value)
Set a header to be used for the push.
|
PushBuilder method(String method)
method
- the method to be used for the push.PushBuilder queryString(String queryString)
path(String)
. 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, or to remove a
query string obtained from the associated request.queryString
- the query string to be used for the push.PushBuilder sessionId(String sessionId)
sessionId
- the SessionID to be used for the push.PushBuilder conditional(boolean conditional)
etag(String)
or
lastModified(String)
will be set in the appropriate headers. If the request
is not conditional, then etag and lastModified values are ignored.
Defaults to true if the associated request was conditional.conditional
- true if the push request is conditionalPushBuilder setHeader(String name, String value)
name
- The header name to setvalue
- The header value to setPushBuilder addHeader(String name, String value)
name
- The header name to addvalue
- The header value to addPushBuilder path(String path)
path(String)
must be called
before every call to push()
path
- the URI path to be used for the push, which may include a
query string.PushBuilder etag(String etag)
isConditional()
is true.
Defaults to no etag. The value is nulled after every call to
push()
etag
- the etag to be used for the push.PushBuilder lastModified(String lastModified)
isConditional()
is true.
Defaults to no date. The value is nulled after every call to
push()
lastModified
- the last modified date to be used for the push.void push()
isConditional()
is true and an etag or lastModified value is provided, then an appropriate conditional header
will be generated. If both an etag and lastModified value are provided only an If-None-Match header
will be generated. 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.
After initiating the push, the builder has its path, etag and lastModified fields nulled. All
other fields are left as is for possible reuse in another push.IllegalArgumentException
- if the method set expects a request body (eg POST)String getMethod()
String getQueryString()
String getSessionId()
boolean isConditional()
String getPath()
String getEtag()
String getLastModified()
Copyright © 1995-2015 Webtide. All Rights Reserved.