Реагировать на собственный запрос извлечения / XMLHttpRequest с несколькими файлами cookie - PullRequest
0 голосов
/ 26 апреля 2018

Я хочу получить несколько значений Set-Cookie с веб-сервера. В настоящее время я получаю только последний Set-Cookie в моем заголовке.
XMLHttpRequest:

 var formData = new FormData();
 formData.append('userId', state.userId);
 formData.append('password', state.password);

 var http = new XMLHttpRequest();
 var url = "http://myurl";
 http.open("POST", url);
 http.setRequestHeader("Content-type", "multipart/form-data");
 http.withCredentials = true;
 http.onreadystatechange = function() {//Call a function when the state changes.
    if(http.readyState == 4 && http.status == 200) {
        console.log(http.responseText);
        console.log(http.getAllResponseHeaders());
    }
}
http.send(formData);

Fetch:

fetch('http://myurl', {
    method: 'POST',
    headers: {
    'Content-Type': 'multipart/form-data',
  },
    credentials: 'same-origin',
    body: formData
 })
 .then((response) => {
   console.log(response);
   console.log(response.headers.getAll('set-cookie'));
   return response.json()
 })
 .then((responseJson) => {
    console.log('responseJson', responseJson);
    console.log('formData', formData);
    setLoginBool(responseJson.success);
 })
 .catch((error) => {
    console.error(error);
 });

Я добавил результат запроса почтальона и журнал результатов выборки. Кажется, только последнее значение Set-Cookie принимается. Результат почтальона результат выборки из журнала

...