[erlang-questions] cowboy etags problems

Nathaniel Waisbrot <>
Mon Jan 16 20:54:11 CET 2017


I agree that the quotes are surprising, but that's how that header works.

Are you sure that you need to run with broken etags? I've used etags from Cowboy with all major browsers and it works correctly. If you've got a broken client you may want to consider fixing the client rather than breaking the server, because you'll just keep encountering surprises (for example, if your client is some home-brewed thing and then you start using a HTTP library that does etags correctly).

But if you want the headers to work some other way, then it shouldn't be too hard. I'd just copy the Cowboy code and modify it as needed: https://github.com/ninenines/cowboy/blob/c5a9771ac4f7844b61b5e36bfc7eb371a082c560/src/cowboy_rest.erl#L673-L697



> On Jan 16, 2017, at 9:57 AM, 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
> 
> http://erlang.org/mailman/listinfo/erlang-questions



More information about the erlang-questions mailing list