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

Setting multiple cookies in header not possible #16

Open
luktor opened this issue Apr 16, 2020 · 0 comments
Open

Setting multiple cookies in header not possible #16

luktor opened this issue Apr 16, 2020 · 0 comments

Comments

@luktor
Copy link

luktor commented Apr 16, 2020

Which platform(s) does your issue occur on?

  • Both

Please, provide the following version numbers that your issue occurs with:

Not relevant as this is a code related thing.

Please, tell us how to recreate the issue in as much detail as possible.

As the headers is in a Map<string, string> it is not possible to use the header parameter Set-Cookie more than for one cookie. I need to set more than one cookie when doing a request and it's not possible as of how a Map works. To be able to set more than one cookie the syntax in a HTTP header is:
Set-Cookie: cookie1=value1
Set-Cookie: cookie2=value2
etc

By the nature of a Map<string, string> there is no way to set more than one and one only value. A way of doing this could be to use a method named WebViewUtils.addHeaders(wv: WebView, headers: Map<string, string[]>) and that in a non destructive manner just adds the the array of header values with the header param name one for each value. Non-destructive in that manner that addHeaders of whatever type can be called multiple times and in that manner build up the total payload of headers.

Is there any code involved? Yes!

// This code does not work. Server will only retrieve cookie2 but both must be included to make a successful request.
const headers: Map<string, string> = new Map();
headers.set('Set-Cookie', 'cookie1=value1');
headers.set('Set-Cookie', 'cookie2=value2');
WebViewUtils.addHeaders(webView, headers);

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

No branches or pull requests

1 participant