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

Set-Cookie Header problem #128

Open
ghost opened this issue Jan 28, 2017 · 1 comment
Open

Set-Cookie Header problem #128

ghost opened this issue Jan 28, 2017 · 1 comment

Comments

@ghost
Copy link

ghost commented Jan 28, 2017

Hello,

I have a problem with getting the Set-Cookie Header from post HTTP requests.
I checked the java code and found this:

protected void addResponseHeaders(HttpRequest request, JSONObject response) throws JSONException {
Map<String, List> headers = request.headers();
Map<String, String> parsed_headers = new HashMap<String, String>();
for (Map.Entry<String, List> entry : headers.entrySet()) {
String key = entry.getKey();
List value = entry.getValue();
if ((key != null) && (!value.isEmpty())) {
parsed_headers.put(key, value.get(0));
}
}
response.put("headers", new JSONObject(parsed_headers));
}

The problem is that "Set-Cookie" is splitted into more header fields. And it only takes the first set-cookie header.
But I need all of them.

@sckumar
Copy link

sckumar commented Mar 2, 2017

@DavidWohlsecker, I tried the below code to get the response header and using it on further requests.
cordovaHTTP.post(url, jsonParam,{"Content-Type":"application/x-www-form-urlencoded"}, function(response) {
try {
cordovaHTTP.setHeader("Cookie", response.headers["Set-Cookie"]);
}
catch(Exception e){
},function(response){
}
});

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