Search code examples
http2http-1.1

How does chunked downloading work in http/2 (or better what is the equivalent?)


In chunked downloading, there are extensions on each chunk that can be leveraged when coming to a browser. the last chunk can also contain optional headers defining stuff like content-length if we streamed a big file through, we can provide that information at the very end in the form of a http header.

How does this work in http/2? Are there even extensions or headers in last piece. I see there is Data payload but there is no extensions nor optional headers AFAICT. I only see padding.

Maybe a better question is do browsers even

  1. leverage the optional headers in the last chunk?
  2. leverage extensions in each chunk?

Perhaps programs may care but if it is a progam, I believe in http/2, the server just defines the api better perhaps and uses a push mechanism after response+data has been sent maybe?

How would one send optional headers in this new http/2 world though if I was a server defining an api for clients?

I was trying to use wireshark to capture a download trace but chrome seems to use QUICK and I can't seem to decrypt the SSL with wireshark for this use case when I use firefox and drive.google.com to download a file(it stays encrypted while in the same trace, I actually saw some http2 traffic in TLS for some other service working just fine). Using the "(Pre)-Master-Secret log filename" seems to only work half the time and I am not quite sure why. I end up having to restart everything and re-run my cases.

Also, in the Server hello, h2 was the protocol selected but then no http2 packets appear when I filter to ip.addr=(server hello google ip) and tcp.port=443

thanks, Dean


Solution

  • In chunked downloading, there are extensions on each chunk that can be leveraged when coming to a browser. the last chunk can also contain optional headers defining stuff like content-length if we streamed a big file through, we can provide that information at the very end in the form of a http header.

    In theory (i.e. standard) you have the extensions and the possibility to add non-essential(!) headers at the end. In practice these feature are not used. I'm not aware of any chunk extensions which are defined which means that browsers simply ignore them. And the example trailer defining a content-length makes no sense because with chunked encoding any content-length header should be ignored. There might be some third party libraries which make use of trailers. But since support for trailers would need to be declared up-front by the client (using TE:trailers header) browsers don't use it.

    If I understand HTTP/2 correctly chunk extensions are simply gone (nothing lost, they were never used). Trailers are still possible, i.e. you could add headers after all data are sent, see RFC7540: 8.1 HTTP Request/Response Exchange.