EddyVerbruggen / EddyVerbruggen/nativescript-webview-utils

Setting multiple cookies in header not possible

Open
#16 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
20
Forks
15
PR merge metrics
No merged PRs in 30d

Description

### 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 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 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) 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 = new Map();
headers.set('Set-Cookie', 'cookie1=value1');
headers.set('Set-Cookie', 'cookie2=value2');
WebViewUtils.addHeaders(webView, headers);

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.