users@servlet-spec.java.net

[servlet-spec users] Re: [jsr340-experts] Re: HTTP/2 Push Was: Server-Sent Events in Java EE 8

From: Edward Burns <edward.burns_at_oracle.com>
Date: Mon, 8 Sep 2014 10:12:20 -0700

>>>>> On Fri, 22 Aug 2014 08:47:31 +1000, Greg Wilkins <gregw_at_intalio.com> said:

GW> So I think the resources should be pushed as soon as they are discovered -
GW> with some obvious protection against duplicate pushes.

I agree with you and like your model better.

GW> So the context could have a method:

GW> context.addAssociatedResource(String uriInContext)
GW> {
GW> associated.add(uriInContext);
GW> ConcurrentSet<String> pushed =
GW> getRequest().getHttpSession().getAttribute("pushed);
GW> if (pushed.addIfAbsent(uriInContext))
GW> getServletContext().getRequestDispatcher(
GW> uriInContext).push(getRequest())
GW> }

GW> that would trigger a push as the associated resource is first added to the
GW> context, using the API that I have proposed.

I don't see why it has to hang off the http session. The set of pushed
resources is a request level concern, not a session one.

Also, and this was brought to my attention by Shing-Wai:

SWC> According to section 8.2.1 of draft-ietf-httpbis-http2-13.txt ,
SWC> the push response should be sent earlier.

Looking at the most recent draft (14):

https://datatracker.ietf.org/doc/draft-ietf-httpbis-http2/

   The server SHOULD send PUSH_PROMISE (Section 6.6) frames prior to
   sending any frames that reference the promised responses. This
   avoids a race where clients issue requests prior to receiving any
   PUSH_PROMISE frames.

   For example, if the server receives a request for a document
   containing embedded links to multiple image files, and the server
   chooses to push those additional images to the client, sending push
   promises before the DATA frames that contain the image links ensures
   that the client is able to see the promises before discovering
   embedded links. Similarly, if the server pushes responses referenced
   by the header block (for instance, in Link header fields), sending
   the push promises before sending the header block ensures that
   clients do not request them.

Greg, you already intimated this requirement but I wanted to make it
explicit for discussion. I perceive a side-effect of this requirement:
the container needs to know when all the PUSH_PROMISE frames pertaining
to this request have been sent, so it can commence sending the HTML
bytes. I've added a request.completedPushRequest() method for this
case.

I've added a wiki page with a diagram for discussion:

https://java.net/projects/servlet-spec/pages/PushAPI

Thoughts?

Thanks,

Ed
-- 
| edward.burns_at_oracle.com | office: +1 407 458 0017
| 14 work days til JavaOne 2014
| 10 work days til start of JSF 2.3 and Servlet 4.0