Search code examples
httpspecificationshttp2server-pushpush-promise

HTTP/2 Push promise behavior


I am working on writing a resilient client for HTTP/2. I am wondering what should be the behavior of the client, if the server sent a PUSH_PROMISE and then failed to send the PUSH_RESPONSE, related to that PUSH_PROMISE ?

I went through the HTTP/2 spec, about the Push Response, but it does not state what should we do in such scenarios.

  • Should we send the original request again, if the push response is not received ? If the original request sent successfully, sending it again may cause issues, isn't it ?
  • Or should we ignore the PUSH_PROMISE and continue ? In that case, say server promised to send a file, and did not send it, what will happen ?

Is there a defined way to resolve this ?


Solution

  • The client is certainly free to request the same resource again. Consider, for example, that the server has no way to know if the client is making a simultaneous request for the same resource when the server sends the PUSH_PROMISE.

    Client                  Server
    ------                  ------
    HEADERS[sid:1, GET /]
                             HEADERS[sid:1, /], DATA [sid:1], PUSH_PROMISE[sid:2]
    HEADERS[sid:3, GET /css] HEADERS[sid:2, /css], DATA[sid:2]
                             HEADERS[sid:3, /css], DATA[sid:3]
    
    
    

    The standard way for the client to then cancel the push would be to reset the promised stream via a RST_STREAM.