haskell-servant / haskell-servant/servant
servant-client-ghcjs converts a `Header "Cookie" a` combinator into an unusable `Maybe a` parameter
- Dominant language
- Haskell
- Stars
- 2k
- Forks
- 427
- Avg merge
- 2d 23h
- Merged PRs (30d)
- 5
Description
`Api.hs`:
```
type Api = Header "Cookie" a :> Post '[JSON] b
```
`Server.hs`
```
server :: ServerT Api m
server = handler
where
handler :: Maybe String -> m b
handler = ...
```
Which is correct, as the cookie may or may not be present.
`Client.hs`
```
clientFunc :: Maybe String -> ClientM b
clientFunc = client (Proxy @Api)
```
Which is incorrect, or at least the current implementation does not handle it properly in modern browsers. Attempting to pass in a value besides `Nothing` gives `Refused to set unsafe header "Cookie"`.
I'm not sure what the best course of action is. The easiest for my specific use case would be a simple `Cookie "my-cookie-name" a` combinator that generated no parameter at all on the client, only one on the server, with the specific cookie parsed out, as I have no intention of overriding the Cookie in the client.
Based on the browser spec different headers kind of do have different client signatures, as some are automatically set and some are for you to specify, but I realize that inspecting the symbol and comparing it with the current browser spec is perhaps a little awkward. So perhaps a `AutoHeader` combinator that is only for the server would be useful.
Contributor guide
Assessment
This issue has not been assessed yet.