

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Still calibrating
click for more info
Not enough gems
Cost: 6 gems
1: Chunked Encoding
incomplete
2: Chunked Quiz 1
incomplete
3: Chunked Quiz 2
incomplete
4: Chunked Quiz 3
incomplete
5: Trailers
incomplete
This lesson's interactive features are locked, please to keep using them
Did you think it was a bit odd that we had to write 0\r\n\r\n (two registered nurses) to signal the end of the chunked encoding?
There's actually a good reason for it – you can have additional headers at the end of chunked encoding, called (of course) Trailers. They work the same way that headers do with one catch: you have to specify the names of the trailers in a Trailer header. For example:
HTTP/1.1 200 OK
Content-Type: text/plain
Transfer-Encoding: chunked
Trailer: Lane, Prime, TJ
1E
I could go for a cup of coffee
C
But not Java
12
Never go full Java
0
Lane: goober
Prime: chill-guy
TJ: 1-indexer
They go between the two \r\n sequences in our original chunked encoding example.
Trailers are often used to send information about the message body that can't be known until the message body is fully sent. For example, the hash of the message body... in fact, let's do that.
Remember, trailers are formatted just like headers.
X-Content-SHA256: <hash>X-Content-Length: <length of raw body in bytes>HTTP header names are case-insensitive by specification. Some servers and clients may canonicalize header names in certain ways (e.g., X-Content-Sha256), so don't be surprised if you notice discrepancies. It's best not to rely on any particular casing when working with headers.
Run and submit the CLI tests with your server running.