July 17th, 2024

Httpwtf?

HTTP has hidden features like cache directives, trailers for metadata, and 1XX codes. Websockets bypass CORS, X-* headers allow custom extensions. Despite quirks, HTTP is vital for client-server communication.

Read original articleLink Icon
Httpwtf?

HTTP is a crucial part of modern development, but it harbors some lesser-known features and quirks. For instance, the "no-cache" directive can actually lead to caching, contrary to its name, while "private" restricts caching to end-client browsers only. Misusing cache control headers can inadvertently store sensitive data, as seen in Twitter's mishap with private messages. Additionally, HTTP trailers allow appending metadata after the message body, useful for protocols like gRPC. HTTP also supports 1XX codes like 100 for interim responses and 101 for protocol switching, commonly used for setting up websockets. Notably, websockets bypass CORS restrictions, potentially exposing vulnerabilities. The use of X-* headers for custom extensions in HTTP requests is a common practice, with examples like X-Shenanigans and X-Requested-With. Despite its quirks, HTTP remains a foundational technology in the digital landscape, facilitating communication and data exchange between clients and servers.

Link Icon 4 comments
By @xg15 - 4 months
Could someone explain why exactly the HTTP 103 header is such a big deal?

Instead of

  HTTP/1.1 103 Early Hints
  Link: foo ...
  Link: bar ...

  <...time-consuming processing...>

  HTTP/1.1 200 OK
  Baz: boo
  <... actual response...>
what stops you from doing

  HTTP/1.1 200 OK
  Link: foo ...
  Link: bar ...
  <...time-consuming processing...>
  Baz: boo
  <... actual response...>
?

The only actual new functionality I see is that you can send the "early hints" headers before having to commit to a status code for the response. Is that it?

By @donatj - 4 months
I've always wished trailers were more powerful. Namely I have wished that they could contain Cookies.

It would make certain types of processing simpler and lighter being able to stream SSR bodies as they are constructed rather than all at once at the end.