1

I am developing an Android video streaming application using the OkHttp library and HTTP/2. I am investigating the possibility of using the server push functionality of the HTTP/2 protocol, but I am not sure whether OkHttp supports it or not.

I have a basic server implementation to test HTTP/2 push, which works without problems on the chrome browser (i.e., pushed content is stored in the cache and retrieved from the cache by the browser). When I use the Android application with the OkHttp library, content is not pushed anymore to the client's cache (which is initialized and working properly, by the way). Particularly, the client sends a reset stream to the server for each content the server would like to push.

Do you have any idea if OkHttp supports push streams? And in case it does support server push, are there any best practices to make it work? Thanks in advance for your answers.

Stefano
  • 11
  • 2

1 Answers1

4

Nothing currently. We’re rewriting the cache persistence and that’s a big effort. If you want to read the internals there’s callbacks for it, but they currently just cancel the pushed streams.

Jesse Wilson
  • 39,078
  • 8
  • 121
  • 128
  • Thanks for your answer. So pushing is not working in any situation?Just to avoid confusion, I would then would like to point out that in the documentation, server-push is specified as a supported functionality (https://square.github.io/okhttp/2.x/okhttp/index.html?com/squareup/okhttp/Protocol.html). – Stefano Oct 23 '16 at 20:13
  • 1
    You’re reading too much into that documentation. That’s just trying to tell you what HTTP/2 is. – Jesse Wilson Nov 04 '16 at 03:40
  • I see, thanks anyway! I was able to use server push by creating a custom "PushObserver" class. Thanks again for your suggestion. – Stefano Nov 16 '16 at 17:12
  • 1
    Sounds good. FYI, everything in the `internal` subpackage is unstable, non-public API. Access those APIs at your own risk. – Jesse Wilson Nov 18 '16 at 05:50
  • Hey Jesse, Do you know if the server-push functionality is something that OKHttp now fully supports? or the previous answers are still accurate? Thanks in advance! – Amilcar Andrade Jan 04 '19 at 21:08
  • No server push thus far. I like early hints better, but it isn't implemented either. https://tools.ietf.org/html/rfc8297#section-2 – Jesse Wilson Jan 06 '19 at 00:39