You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Brian Clozel <bc...@pivotal.io> on 2016/09/29 14:30:40 UTC

HTTP/2 PushBuilder.push() synchronous?

Hi,

Looking at previous Servlet 4.0 EG e-mails [1] and the PushBuilder.push()
API [2], it seems the current version returns true if the PUSH_PROMISE
frame + headers were sent, meaning the client can still reset that stream
and refuse to receive the response that goes with it.

Now looking at former EG e-mails, it seems that a previous version of the
spec stated that push "returns immediately without blocking" [3]. But this
API, and the implementation as far as I understand things [4], seems
synchronous. Or does that writing does not happen directly on the actual
socket but is later dispatched on another thread?

In general, I'm trying to understand how I can use that API in an async,
non-blocking way and if the application really needs to know if the Push
promise "happened" or not...

Cheers,

[1] https://java.net/projects/servlet-spec/lists/jsr369-
experts/archive/2016-03/message/0
[2] https://github.com/apache/tomcat/blob/trunk/java/javax/s
ervlet/http/PushBuilder.java#L161-L178
[3] https://java.net/projects/servlet-spec/lists/jsr369-expe
rts/archive/2015-12/message/8
[4] https://github.com/apache/tomcat/blob/trunk/java/org/apa
che/coyote/http2/Http2UpgradeHandler.java#L1036
--
Brian Clozel

Re: HTTP/2 PushBuilder.push() synchronous?

Posted by Mark Thomas <ma...@apache.org>.
On 29 September 2016 15:30:40 BST, Brian Clozel <bc...@pivotal.io> wrote:
>Hi,
>
>Looking at previous Servlet 4.0 EG e-mails [1] and the
>PushBuilder.push()
>API [2], it seems the current version returns true if the PUSH_PROMISE
>frame + headers were sent, meaning the client can still reset that
>stream
>and refuse to receive the response that goes with it.

Not quite. It returns true if the push is accepted by the server. I'm on my phone so looking at the code is tricky. I can't remember if an error triggers an exception or returns false.

>Now looking at former EG e-mails, it seems that a previous version of
>the
>spec stated that push "returns immediately without blocking" [3]. But
>this
>API, and the implementation as far as I understand things [4], seems
>synchronous. Or does that writing does not happen directly on the
>actual
>socket but is later dispatched on another thread?

The push is built on the current thread and then passed to a separate thread for processing. The idea being to catch as many errors as possible on the current thread.

The client is free to reset the pushed steam at any point. 

HTH,

Mark


>In general, I'm trying to understand how I can use that API in an
>async,
>non-blocking way and if the application really needs to know if the
>Push
>promise "happened" or not...
>
>Cheers,
>
>[1] https://java.net/projects/servlet-spec/lists/jsr369-
>experts/archive/2016-03/message/0
>[2] https://github.com/apache/tomcat/blob/trunk/java/javax/s
>ervlet/http/PushBuilder.java#L161-L178
>[3] https://java.net/projects/servlet-spec/lists/jsr369-expe
>rts/archive/2015-12/message/8
>[4] https://github.com/apache/tomcat/blob/trunk/java/org/apa
>che/coyote/http2/Http2UpgradeHandler.java#L1036
>--
>Brian Clozel



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org