ring

jf 2025-07-29T15:35:23.161999Z

is there any interest in supporting storing information relating to the order of headers in Ring? For the context of how I got to thinking about this, see the discussion over at https://github.com/pedestal/pedestal/issues/930. Specifically, this is why storing this info might be helpful: • to determine which header is the last for the purposes of dealing with multiple singleton fields (`Content-Type` https://www.rfc-editor.org/rfc/rfc9110.html#section-8.3-7 in RFC9110) • for cases where duplicate headers are sent and it matters what order they are sent in (e.g. X-Forwarded-For)

jf 2025-07-29T15:58:44.719769Z

is there a reason why request header names are https://github.com/ring-clojure/ring/blob/master/SPEC.md#headers in the spec; but nothing is said of response header names?

weavejester 2025-08-01T19:51:43.281529Z

HTTP headers are case insensitive, so in order to get a predictable key, they are lowercased in the request map. However, the headers in the response are placed there by the developer, and they may have reasons for choosing a particular case. For example, perhaps they're working with a faulty client that expects an exact header string, matched case-sensitively. It's also more common for middleware to need to read headers in the request than the response.

jf 2025-08-02T14:58:21.974609Z

sure. Here's one question to help clarify things: does all middleware theoretically need to conform to the spec? or does "request" and "response" only refer to the actual beginning and end of the entire "pipe"?

weavejester 2025-08-02T15:21:41.556129Z

Ring middleware is specifically defined as a function that transforms a Ring handler into another Ring handler. However, there's nothing stopping you inserting a function into the chain that doesn't do this; it just wouldn't be Ring middleware.

jf 2025-08-03T04:01:01.359339Z

right! sorry about that. Yes you're right...

mpenet 2025-07-29T16:59:15.473229Z

Probably to make it predictable when reading them across middlewares

jf 2025-07-29T23:21:03.931289Z

thanks. I think i get it now; there is no specific requirement per se for response maps (after all, header names are case-insensitive for HTTP), but practically, because of the requirement for lowercase for request maps, effectively then response maps are the same because of the architecture of how things are: middleware, etc. One component’s response map tends to be the request map for the next!