Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect handling of Set-Cookie header #68

Open
ebruchez opened this issue Aug 23, 2017 · 2 comments
Open

Incorrect handling of Set-Cookie header #68

ebruchez opened this issue Aug 23, 2017 · 2 comments

Comments

@ebruchez
Copy link

As per the Node doc:

set-cookie is always an array. Duplicates are added to the array.

Yet SimpleHttpResponse.headers are an HeaderMap[String]. But at runtime, headers.get("Set-Cookie") returns a js.Array[String] instead of a String.

(Just discussed the issue today on the Scala.js Gitter.)

@ebruchez
Copy link
Author

ebruchez commented Aug 23, 2017

Workaround:

headers.asInstanceOf[fr.hmil.roshttp.util.HeaderMap[Any]].get("Set-Cookie") map
  (_.asInstanceOf[js.Array[String]])

@hmil
Copy link
Owner

hmil commented Aug 24, 2017

Thanks @ebruchez for pointing this out. This issue is open for PRs
A correct fix has to take care of the following points:

*The API change should be non-breaking. Although the current API assumes headers are unique, that is still what you will want in most cases. However, some utility function should be added to allow retrieval of header arrays. No special treatment should be granted to any particular header at least from the public API point of view. If a backend does change the return type for some specific header, this should be handled and not show on the public API (the node driver will need a lot of duct tape there).

As per the Node doc:

Never realized this API was that much broken. A scala frontend can definitely make it safer to use 😉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants