[erlang-questions] cowboy etags problems

Loïc Hoguin essen@REDACTED
Mon Jan 16 22:27:00 CET 2017

Write a middleware that changes the header and add the quotes back, if 
you really really want to support this behavior.

Note that in Cowboy 2 that answer will change to "write a stream 
handler" which is a kind of low level middleware in Cowboy 2, and will 
fix the invalid header much earlier, ensuring it works across more than 

On 01/16/2017 03:57 PM, Garry Hodgson wrote:
> I have an application that acts as an http proxy, accepting REST api
> calls, forwarding to appropriate endpoints, and returning result. It's
> built atop Cowboy, and generally works well.
> However, while exploring a reported bug I discovered that I was not
> handling etags properly. Whenever an if-match header was included,
> Cowboy returned a 400, before my code ever saw the request. I eventually
> discovered that I was being sent headers like: If-Match: 1234567
> Instead of: If-Match: "1234567"
> Digging into the RFC it appears that Cowboy is handling this properly,
> as the surrounding quotes are part of the spec. But it will still cause
> problems for my users.
> When I pass the correct If-Match header, I get a 412 Precondition
> Failed. This also appears to be correct behavior, as my Cowboy instance
> doesn't have the etag, the eventual endpoint should. So I think what I
> really need to do is to turn off If-Match handling in Cowboy and just
> pass through the headers I get, or possibly intercept the request before
> Cowboy looks at this and massage the inputs/outputs.
> Am I correct in this diagnosis? Is there any way to solve this? It's
> kind of a showstopper.
> Any insights appreciated.
> Thanks
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions

Loïc Hoguin

More information about the erlang-questions mailing list