haskell-servant / servant-elm

Automatically derive Elm functions to query servant webservices
BSD 3-Clause "New" or "Revised" License
164 stars 48 forks source link

Filter out forbidden headers #37

Closed nicklawls closed 6 years ago

nicklawls commented 6 years ago

One of our servant API endpoints specifies the Cookie header in the request, and so servant-elm happily generates elm code to set that header. This code throws a js runtime error.

Turns out "Cookie" is one of a list of forbidden header names that can't be set programmatically. The browser sets the cookie header automatically, I'm not sure about all the others.

This patch currently just filters any headers matching "Cookie" out of the list comprehensions that generate types, header args, and Http function calls.

I'm more than happy to extend it to work with all the forbidden headers, and/or implement it in a different style if you prefer.

mattjbray commented 6 years ago

Thanks! Merged in 662c3a880772ebbec7be63625bddb1ab42b56532.