Fixed handling of array values for AxiosHeaders;
Fixed handling of `set-cookie` headers as an array;
Closes #5028, #5083;
<!-- Click "Preview" for a more readable version --

Please read and follow the instructions before submitting an issue:

- Read all our documentation, especially the [README](https://github.com/axios/axios/blob/master/README.md). It may contain information that helps you solve your issue.
- Ensure your issue isn't already [reported](https://github.com/axios/axios/issues?utf8=%E2%9C%93&q=is%3Aissue).
- If you aren't sure that the issue is caused by Axios or you just need help, please use [Stack Overflow](https://stackoverflow.com/questions/tagged/axios) or [our chat](https://gitter.im/mzabriskie/axios).
- If you're reporting a bug, ensure it isn't already fixed in the latest Axios version.
- Don't remove any title of the issue template, or it will be treated as invalid by the bot.

⚠️👆 Feel free to these instructions before submitting the issue 👆⚠️
-->

#### Describe the bug
In v1, accessing the 'Set-Cookie' header in a response interceptor yields the raw string value of the header.

#### To Reproduce

```js
const axios = require('axios'),
      http = require('http');

const server = http
        .createServer((req, res) => {
          res.setHeader('Set-Cookie', 'my=value');
          res.writeHead(200);
          res.write('Hi there');
          res.end();
        })
        .listen(0),
      request = axios.create();

request.interceptors.response.use((res) => {
  console.log(res.headers['set-cookie']);
});

request({ url: `http://localhost:${server.address().port}` }).then(() => server.close());
```

The produces `my=value`

#### Expected behavior
`[ 'my=value' ]`

#### Environment
 - Axios Version [e.g. 0.18.0]: 1.0.0
 - Adapter [e.g. XHR/HTTP]: http
 - Browser [e.g. Chrome, Safari]: N/A
 - Browser Version [e.g. 22]: N/A
 - Node.js Version [e.g. 13.0.1]: 16.13.0
 - OS: [e.g. iOS 12.1.0, OSX 10.13.4]: Ubuntu 20.04
 - Additional Library Versions [e.g. React 16.7, React Native 0.58.0]: N/A

#### Additional context/Screenshots

N/A
[1.0.0] Set-Cookie header in a response interceptor is not an array anymore
diff --git a/index.d.ts b/index.d.ts
index 806e32284e..c193d1d664 100644
--- a/index.d.ts
+++ b/index.d.ts
@@ -39,7 +39,7 @@ export class AxiosHeaders {
 
   normalize(format: boolean): AxiosHeaders;
 
-  toJSON(): RawAxiosHeaders;
+  toJSON(asStrings?: boolean): RawAxiosHeaders;
 
   static from(thing?: AxiosHeaders | RawAxiosHeaders | string): AxiosHeaders;
 
diff --git a/lib/core/AxiosHeaders.js b/lib/core/AxiosHeaders.js
index 9d5653860f..68e098a0f7 100644
--- a/lib/core/AxiosHeaders.js
+++ b/lib/core/AxiosHeaders.js
@@ -15,7 +15,7 @@ function normalizeValue(value) {
     return value;
   }
 
-  return String(value);
+  return utils.isArray(value) ? value.map(normalizeValue) : String(value);
 }
 
 function parseTokens(str) {
@@ -102,13 +102,7 @@ Object.assign(AxiosHeaders.prototype, {
         return;
       }
 
-      if (utils.isArray(_value)) {
-        _value = _value.map(normalizeValue);
-      } else {
-        _value = normalizeValue(_value);
-      }
-
-      self[key || _header] = _value;
+      self[key || _header] = normalizeValue(_value);
     }
 
     if (utils.isPlainObject(header)) {
@@ -222,13 +216,13 @@ Object.assign(AxiosHeaders.prototype, {
     return this;
   },
 
-  toJSON: function() {
+  toJSON: function(asStrings) {
     const obj = Object.create(null);
 
     utils.forEach(Object.assign({}, this[$defaults] || null, this),
       (value, header) => {
         if (value == null || value === false) return;
-        obj[header] = utils.isArray(value) ? value.join(', ') : value;
+        obj[header] = asStrings && utils.isArray(value) ? value.join(', ') : value;
       });
 
     return obj;

diff --git a/test/unit/core/AxiosHeaders.js b/test/unit/core/AxiosHeaders.js
index da7be11f97..aa30091982 100644
--- a/test/unit/core/AxiosHeaders.js
+++ b/test/unit/core/AxiosHeaders.js
@@ -327,5 +327,15 @@ describe('AxiosHeaders', function () {
         bar: '3'
       });
     });
+
+    it('should support array values', function () {
+      const headers = new AxiosHeaders({
+        foo: [1,2,3]
+      });
+
+      assert.deepStrictEqual({...headers.normalize().toJSON()}, {
+        foo: ['1','2','3']
+      });
+    });
   });
 });
diff --git a/test/unit/regression/bugs.js b/test/unit/regression/bugs.js
index 1a660507b1..a9d1509fde 100644
--- a/test/unit/regression/bugs.js
+++ b/test/unit/regression/bugs.js
@@ -1,4 +1,5 @@
 import assert from 'assert';
+import http from 'http';
 import axios from '../../../index.js';
 
 describe('issues', function () {
@@ -10,4 +11,33 @@ describe('issues', function () {
       assert.strictEqual(data.args.foo2, 'bar2');
     });
   });
+
+  describe('5028', function () {
+    it('should handle set-cookie headers as an array', async function () {
+      const cookie1 = 'something=else; path=/; expires=Wed, 12 Apr 2023 12:03:42 GMT; samesite=lax; secure; httponly';
+      const cookie2 = 'something-ssr.sig=n4MlwVAaxQAxhbdJO5XbUpDw-lA; path=/; expires=Wed, 12 Apr 2023 12:03:42 GMT; samesite=lax; secure; httponly';
+
+      const server = http.createServer((req, res) => {
+            //res.setHeader('Set-Cookie', 'my=value');
+            res.setHeader('Set-Cookie', [cookie1, cookie2]);
+            res.writeHead(200);
+            res.write('Hi there');
+            res.end();
+          }).listen(0);
+
+      const request = axios.create();
+
+      request.interceptors.response.use((res) => {
+        assert.deepStrictEqual(res.headers['set-cookie'], [
+          cookie1, cookie2
+        ]);
+      });
+
+      try {
+        await request({url: `http://localhost:${server.address().port}`});
+      } finally {
+        server.close()
+      }
+    });
+  });
 });

{"should support array values": {"run": "NONE", "test": "FAIL", "fix": "PASS"}}
{"should support requesting data URL as a Blob (if supported by the environment)": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "should support beforeRedirect and proxy with redirect": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "should re-evaluate proxy on redirect when proxy set via env var": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "should support HTTP proxy auth": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "should support HTTPS proxy set via env var": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "should return true if the header has been deleted, otherwise false": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "should support requesting data URL as a Stream": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "should detect the FormData instance provided by the `form-data` package": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "should return buffer from data uri": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "should use proxy for domains not in no_proxy": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "should not fail with query parsing": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "should not use proxy for domains in no_proxy": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "should support headers argument": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "does not parse undefined": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "should pass errors for a failed stream": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "should delete the header": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "should validate Stream": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "should not rewrite the header if its value is false, unless rewrite options is set to true": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "should support proxy auth with header": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "should able to cancel multiple requests with CancelToken": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "should support RegExp": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "should support HTTPS proxies": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "parses json": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "should return true if the header is defined, otherwise false": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "should be caseless": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "should support headers array": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "should not rewrite header the header if the value is false": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "should support set accessor": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "should support gunzip error handling": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "should support max body length": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "ignores XML": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "should support requesting data URL as a Buffer": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "should support requesting data URL as a String": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "should validate Buffer": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "should support proxy auth from env": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "should return unsupported protocol": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "should return headers object with original headers case": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "should support function": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "should support string pattern": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "should display error while parsing params": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "should support adding a single header": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "should throw an error if the timeout property is not parsable as a number": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "should support HTTP proxies": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "should not pass through disabled proxy": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "should support get accessor": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "does not parse the empty string": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "should support proxy set via env var": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "should support auto-formatting": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "should support sockets": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "should return malformed URL": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "should support adding multiple headers": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "should parse protocol part if it exists": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "obeys proxy settings when following redirects": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "should support has accessor": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "should support external defined values": {"run": "PASS", "test": "PASS", "fix": "PASS"}}
{"should support array values": {"run": "NONE", "test": "FAIL", "fix": "PASS"}}
{"passed_count": 56, "failed_count": 40, "skipped_count": 0, "passed_tests": ["should support requesting data URL as a Blob (if supported by the environment)", "should support beforeRedirect and proxy with redirect", "should parse the timeout property", "should re-evaluate proxy on redirect when proxy set via env var", "should support requesting data URL as a String", "should support HTTP proxy auth", "should validate Buffer", "should support proxy auth from env", "should support HTTPS proxy set via env var", "should return unsupported protocol", "should support requesting data URL as a Stream", "should return true if the header has been deleted, otherwise false", "should return headers object with original headers case", "should support function", "should support string pattern", "should display error while parsing params", "should support adding a single header", "should throw an error if the timeout property is not parsable as a number", "should return buffer from data uri", "should detect the FormData instance provided by the `form-data` package", "should support HTTP proxies", "should use proxy for domains not in no_proxy", "should not pass through disabled proxy", "should support get accessor", "does not parse the empty string", "should not fail with query parsing", "should not use proxy for domains in no_proxy", "should support headers argument", "does not parse undefined", "should support proxy set via env var", "should pass errors for a failed stream", "should support auto-formatting", "should delete the header", "should validate Stream", "should support sockets", "should return malformed URL", "should support adding multiple headers", "should support proxy auth with header", "should able to cancel multiple requests with CancelToken", "should not rewrite the header if its value is false, unless rewrite options is set to true", "should parse protocol part if it exists", "obeys proxy settings when following redirects", "should support RegExp", "should support HTTPS proxies", "should support has accessor", "parses json", "should return true if the header is defined, otherwise false", "should be caseless", "should support headers array", "should not rewrite header the header if the value is false", "should support set accessor", "should support gunzip error handling", "should support max body length", "should support external defined values", "ignores XML", "should support requesting data URL as a Buffer"], "failed_tests": ["should post object data as url-encoded form if content-type is application/x-www-form-urlencoded", "should support transparent gunzip", "should properly support default max body length (follow-redirects as well)", "should respect formSerializer config", "should support download progress capturing", "should combine baseURL and url", "should be able to abort the response stream", "should allow passing JSON with BOM", "should support HTTP protocol", "should support max content length for redirected", "should support max redirects", "should preserve the HTTP verb on redirect", "should support disabling automatic decompression of response data", "should allow the User-Agent header to be overridden", "should respect the timeoutErrorMessage property", "should supply a user-agent if one is not specified", "should allow passing FormData", "should support buffers", "should support cancel", "should support download rate limit", "should properly serialize nested objects for parsing with multer.js (express.js)", "should support basic auth", "should support upload progress capturing", "should support basic auth with a header", "should respect the timeout property", "supports http with nodejs", "should throw an error if http server that aborts a chunked request", "should provides a default User-Agent header", "should support beforeRedirect", "should support HTTPS protocol", "should not redirect", "should support UTF8", "should support streams", "should allow the Content-Length header to be overridden", "should redirect", "should support upload rate limit", "should support max content length", "should destroy the response stream with an error on request stream destroying", "should allow passing JSON", "should omit a user-agent if one is explicitly disclaimed"], "skipped_tests": []}
{"passed_count": 55, "failed_count": 45, "skipped_count": 0, "passed_tests": ["should support requesting data URL as a Blob (if supported by the environment)", "should support beforeRedirect and proxy with redirect", "should re-evaluate proxy on redirect when proxy set via env var", "should support requesting data URL as a String", "should support HTTP proxy auth", "should validate Buffer", "should return unsupported protocol", "should support proxy auth from env", "should support HTTPS proxy set via env var", "should support requesting data URL as a Stream", "should return true if the header has been deleted, otherwise false", "should return headers object with original headers case", "should support function", "should support string pattern", "should display error while parsing params", "should support adding a single header", "should throw an error if the timeout property is not parsable as a number", "should return buffer from data uri", "should detect the FormData instance provided by the `form-data` package", "should support HTTP proxies", "should use proxy for domains not in no_proxy", "should not pass through disabled proxy", "should support get accessor", "does not parse the empty string", "should not fail with query parsing", "should not use proxy for domains in no_proxy", "should support headers argument", "does not parse undefined", "should support proxy set via env var", "should pass errors for a failed stream", "should support auto-formatting", "should delete the header", "should validate Stream", "should support sockets", "should return malformed URL", "should support adding multiple headers", "should support proxy auth with header", "should able to cancel multiple requests with CancelToken", "should not rewrite the header if its value is false, unless rewrite options is set to true", "should parse protocol part if it exists", "obeys proxy settings when following redirects", "should support RegExp", "should support HTTPS proxies", "should support has accessor", "parses json", "should return true if the header is defined, otherwise false", "should be caseless", "should support headers array", "should not rewrite header the header if the value is false", "should support set accessor", "should support gunzip error handling", "should support max body length", "should support external defined values", "ignores XML", "should support requesting data URL as a Buffer"], "failed_tests": ["should post object data as url-encoded form if content-type is application/x-www-form-urlencoded", "should parse the timeout property", "should support transparent gunzip", "should properly support default max body length (follow-redirects as well)", "should respect formSerializer config", "should support download progress capturing", "issues", "should combine baseURL and url", "AxiosHeaders", "should be able to abort the response stream", "should allow passing JSON with BOM", "should support HTTP protocol", "should support max content length for redirected", "should support max redirects", "should preserve the HTTP verb on redirect", "should support array values", "should support disabling automatic decompression of response data", "should allow the User-Agent header to be overridden", "should respect the timeoutErrorMessage property", "should supply a user-agent if one is not specified", "should allow passing FormData", "should support buffers", "should support cancel", "should support download rate limit", "should properly serialize nested objects for parsing with multer.js (express.js)", "should support basic auth", "should support upload progress capturing", "should support basic auth with a header", "should respect the timeout property", "supports http with nodejs", "should throw an error if http server that aborts a chunked request", "should provides a default User-Agent header", "should support beforeRedirect", "should support HTTPS protocol", "should not redirect", "should handle set-cookie headers as an array", "should support UTF8", "should support streams", "should allow the Content-Length header to be overridden", "should redirect", "should support upload rate limit", "should support max content length", "should destroy the response stream with an error on request stream destroying", "should allow passing JSON", "should omit a user-agent if one is explicitly disclaimed"], "skipped_tests": []}
{"passed_count": 56, "failed_count": 43, "skipped_count": 0, "passed_tests": ["should support requesting data URL as a Blob (if supported by the environment)", "should support beforeRedirect and proxy with redirect", "should re-evaluate proxy on redirect when proxy set via env var", "should support requesting data URL as a String", "should support HTTP proxy auth", "should validate Buffer", "should return unsupported protocol", "should support proxy auth from env", "should support HTTPS proxy set via env var", "should support requesting data URL as a Stream", "should return true if the header has been deleted, otherwise false", "should return headers object with original headers case", "should support function", "should support string pattern", "should display error while parsing params", "should support adding a single header", "should throw an error if the timeout property is not parsable as a number", "should return buffer from data uri", "should detect the FormData instance provided by the `form-data` package", "should support HTTP proxies", "should support array values", "should use proxy for domains not in no_proxy", "should not pass through disabled proxy", "should support get accessor", "does not parse the empty string", "should not fail with query parsing", "should not use proxy for domains in no_proxy", "should support headers argument", "does not parse undefined", "should support proxy set via env var", "should pass errors for a failed stream", "should support auto-formatting", "should delete the header", "should validate Stream", "should support sockets", "should return malformed URL", "should support adding multiple headers", "should support proxy auth with header", "should able to cancel multiple requests with CancelToken", "should not rewrite the header if its value is false, unless rewrite options is set to true", "should parse protocol part if it exists", "obeys proxy settings when following redirects", "should support RegExp", "should support HTTPS proxies", "should support has accessor", "parses json", "should return true if the header is defined, otherwise false", "should be caseless", "should support headers array", "should not rewrite header the header if the value is false", "should support set accessor", "should support gunzip error handling", "should support max body length", "should support external defined values", "ignores XML", "should support requesting data URL as a Buffer"], "failed_tests": ["should post object data as url-encoded form if content-type is application/x-www-form-urlencoded", "should parse the timeout property", "should support transparent gunzip", "should properly support default max body length (follow-redirects as well)", "should respect formSerializer config", "should support download progress capturing", "issues", "should combine baseURL and url", "should be able to abort the response stream", "should allow passing JSON with BOM", "should support HTTP protocol", "should support max content length for redirected", "should support max redirects", "should preserve the HTTP verb on redirect", "should support disabling automatic decompression of response data", "should allow the User-Agent header to be overridden", "should respect the timeoutErrorMessage property", "should supply a user-agent if one is not specified", "should allow passing FormData", "should support buffers", "should support cancel", "should support download rate limit", "should properly serialize nested objects for parsing with multer.js (express.js)", "should support basic auth", "should support upload progress capturing", "should support basic auth with a header", "should respect the timeout property", "supports http with nodejs", "should throw an error if http server that aborts a chunked request", "should provides a default User-Agent header", "should support beforeRedirect", "should support HTTPS protocol", "should not redirect", "should handle set-cookie headers as an array", "should support UTF8", "should support streams", "should allow the Content-Length header to be overridden", "should redirect", "should support upload rate limit", "should support max content length", "should destroy the response stream with an error on request stream destroying", "should allow passing JSON", "should omit a user-agent if one is explicitly disclaimed"], "skipped_tests": []}