purescript-node/purescript-node-http

responseHeaders's runtime representation isn't necessarily a StrMap String

Closed this issue · 3 comments

When running tests for one of my libraries, I tried to print the responseHeaders from a Response and got the following:

Response headers:

TypeError: s.replace is not a function
    at exports.showStringImpl (/home/thimotron/Programming/purescript-simple-request/output/Prelude/foreign.js:23
1:19)

I tracked it down to the fact that the responseHeaders in question had a "set-cookie" key with an Array String value.

argh node: https://nodejs.org/api/http.html#http_message_headers

Seems like it's just "set-cookie" that we have to worry about.

How terrible would it be to give it a StrMap Foreign type?

That would be better than what we have now. Since we know it's either String or Array String, though, I think I'd rather define a foreign type HeaderValue or something, and then provide a function HeaderValue -> Either String (Array String). Also open to other suggestions.