ring-clojure / ring

Clojure HTTP server abstraction
MIT License
3.78k stars 520 forks source link

ring.util.response generates non-lowercase headers, contradicting the spec #514

Closed opqdonut closed 1 week ago

opqdonut commented 1 week ago

According to the spec, the keys in the headers map should be lowercased.

https://github.com/ring-clojure/ring/blob/master/SPEC.md#headers-1

At least the ring.util.response/content-type util produces a mixed-case header, "Content-Type". Probably other utils do the same.

https://github.com/ring-clojure/ring/blob/f7dfe7c9b98c335e4573e61d94c523d5df9a6667/ring-core/src/ring/util/response.clj#L184

We discovered this while looking into metosin/ring-http-response#35 .

Would a PR be welcome?

weavejester commented 1 week ago

Yes, but in this case the error is with the spec, not the middleware. It looks like when I was converting the spec to markdown a mistake was made.

Thanks for the spot, I'll go ahead and fix it.

weavejester commented 1 week ago

To clarify further, I converted the current markdown-based spec from work I was doing on Ring 2.0. My original plan for 2.0 was to make the response headers consistently lowercase to make them easier to access by middleware. However, this would be a breaking change from the 1.x specs.

I eventually abandoned the work on Ring 2.0, as the breaking changes I wanted weren't enough to justify running two separate specs, or trying to make Ring work with both. I may return to it in future at some point.