Server Push

Note: Before explaining how to set it up, I ask you to carefully analyze whether you need this. Server Push benefits mostly clients which can prioritize resource fetching to optimize other flows (p.ex.: browser rendering cycle), but don’t help much in server-to-server HTTP interactions. In fact, in order to reliably support Server Push, one has to throttle request concurrency.

That being said, here’s how you can use it. Remember that HTTP/2 PUSH streams are only accepted if the pushed request is in the pendinng list of requests:

http = HTTPX.plugin(:push_promise)
responses = http.get("https://www.google.com", "https://www.google.com/styles.css")
# request https://www.google.com
# server sends PUSH frame for https://www.google.com/styles.css
# server sends PUSH frame for https://www.google.com/styles.js
# client accepts first stream
# client rejects second stream

Next: Upgrade