@@ -179,6 +179,14 @@ changes:
179
179
** Default:** ` 'lifo' ` .
180
180
* ` timeout ` {number} Socket timeout in milliseconds.
181
181
This will set the timeout when the socket is created.
182
+ * ` separateHeadersValues ` {boolean} If set to ` true ` , the request and the
183
+ response headers will never be squashed.
184
+ All request headers will be sent multiple times if the header
185
+ value was set to an array or set multiple times.
186
+ All response headers will always be returned as a string if the
187
+ header has been received once or as an array of strings if the header has
188
+ been received multiple times.
189
+ In both cases headers matching is case insensitive.
182
190
183
191
` options ` in [ ` socket.connect() ` ] [ ] are also supported.
184
192
983
991
request .setHeader (' Cookie' , [' type=ninja' , ' language=javascript' ]);
984
992
```
985
993
994
+ If ` separateHeadersValues ` was set to ` true ` when the request was created, then
995
+ using this method will always append a new value to the list of values for this
996
+ header.
997
+
986
998
### ` request.setNoDelay([noDelay]) `
987
999
988
1000
<!-- YAML
@@ -1629,6 +1641,10 @@ Reads out a header that's already been queued but not sent to the client.
1629
1641
The name is case-insensitive. The type of the return value depends
1630
1642
on the arguments provided to [ ` response.setHeader() ` ] [ ] .
1631
1643
1644
+ If ` separateHeadersValues ` was set to ` true ` when the server was created, then
1645
+ the return value is always a string if the header has been set once or
1646
+ an array of strings if the header has been set multiple times.
1647
+
1632
1648
``` js
1633
1649
response .setHeader (' Content-Type' , ' text/html' );
1634
1650
response .setHeader (' Content-Length' , Buffer .byteLength (body));
@@ -1652,6 +1668,9 @@ added: v7.7.0
1652
1668
Returns an array containing the unique names of the current outgoing headers.
1653
1669
All header names are lowercase.
1654
1670
1671
+ If ` separateHeadersValues ` was set to ` true ` when the server was created, an
1672
+ header might be present in the list more than once.
1673
+
1655
1674
``` js
1656
1675
response .setHeader (' Foo' , ' bar' );
1657
1676
response .setHeader (' Set-Cookie' , [' foo=bar' , ' bar=baz' ]);
@@ -1679,6 +1698,10 @@ prototypically inherit from the JavaScript `Object`. This means that typical
1679
1698
` Object ` methods such as ` obj.toString() ` , ` obj.hasOwnProperty() ` , and others
1680
1699
are not defined and _ will not work_ .
1681
1700
1701
+ If ` separateHeadersValues ` was set to ` true ` when the server was created, then
1702
+ the values are always a string if the header will be sent once or
1703
+ an array of strings if the header will be sent multiple times.
1704
+
1682
1705
``` js
1683
1706
response .setHeader (' Foo' , ' bar' );
1684
1707
response .setHeader (' Set-Cookie' , [' foo=bar' , ' bar=baz' ]);
@@ -1788,6 +1811,10 @@ When headers have been set with [`response.setHeader()`][], they will be merged
1788
1811
with any headers passed to [ ` response.writeHead() ` ] [ ] , with the headers passed
1789
1812
to [ ` response.writeHead() ` ] [ ] given precedence.
1790
1813
1814
+ If ` separateHeadersValues ` was set to ` true ` when the request was created, then
1815
+ using this method will always append a new value to the list of values for this
1816
+ header.
1817
+
1791
1818
``` js
1792
1819
// Returns content-type = text/plain
1793
1820
const server = http .createServer ((req , res ) => {
@@ -2551,11 +2578,15 @@ added: v0.4.0
2551
2578
-->
2552
2579
2553
2580
* ` name ` {string} Name of header
2554
- * Returns {string | undefined}
2581
+ * Returns {string | string \[ ] | undefined}
2555
2582
2556
2583
Gets the value of HTTP header with the given name. If such a name doesn't
2557
2584
exist in message, it will be ` undefined ` .
2558
2585
2586
+ If ` separateHeadersValues ` was set to ` true ` when the request or the server
2587
+ were created, then the return value is always a string if the header has been
2588
+ set once or an array of strings if the header has been set multiple times.
2589
+
2559
2590
### ` outgoingMessage.getHeaderNames() `
2560
2591
2561
2592
<!-- YAML
@@ -2567,6 +2598,9 @@ added: v8.0.0
2567
2598
Returns an array of names of headers of the outgoing outgoingMessage. All
2568
2599
names are lowercase.
2569
2600
2601
+ If ` separateHeadersValues ` was set to ` true ` when the request or the server
2602
+ were created, an header might be present in the list more than once.
2603
+
2570
2604
### ` outgoingMessage.getHeaders() `
2571
2605
2572
2606
<!-- YAML
@@ -2594,6 +2628,10 @@ const headers = outgoingMessage.getHeaders();
2594
2628
// headers === { foo: 'bar', 'set-cookie': ['foo=bar', 'bar=baz'] }
2595
2629
```
2596
2630
2631
+ If ` separateHeadersValues ` was set to ` true ` when the request or the server
2632
+ were created, then the values are always a string if the header will be sent
2633
+ once or an array of strings if the header will be sent multiple times.
2634
+
2597
2635
### ` outgoingMessage.hasHeader(name) `
2598
2636
2599
2637
<!-- YAML
@@ -2659,6 +2697,10 @@ added: v0.4.0
2659
2697
2660
2698
Sets a single header value for the header object.
2661
2699
2700
+ If ` separateHeadersValues ` was set to ` true ` when the request or the server
2701
+ were created, then using this method will always append a new value to the list
2702
+ of values for this header.
2703
+
2662
2704
### ` outgoingMessage.setTimeout(msesc[, callback]) `
2663
2705
2664
2706
<!-- YAML
@@ -2865,6 +2907,14 @@ changes:
2865
2907
[ ` --max-http-header-size ` ] [ ] for requests received by this server, i.e.
2866
2908
the maximum length of request headers in bytes.
2867
2909
** Default:** 16384 (16 KB).
2910
+ * ` separateHeadersValues ` {boolean} If set to ` true ` , incoming requests and
2911
+ server responses headers will never be squashed.
2912
+ All incoming requests headers will always be returned as a string if the
2913
+ header has been received once or as an array of strings if the header has
2914
+ been received multiple times.
2915
+ All server responses headers will be sent multiple times if the header
2916
+ value was set to an array or set multiple times.
2917
+ In both cases headers matching is case insensitive.
2868
2918
2869
2919
* ` requestListener ` {Function}
2870
2920
@@ -3072,6 +3122,14 @@ changes:
3072
3122
` hostname ` . Valid values are ` 4 ` or ` 6 ` . When unspecified, both IP v4 and
3073
3123
v6 will be used.
3074
3124
* ` headers ` {Object} An object containing request headers.
3125
+ * ` separateHeadersValues ` {boolean} If set to ` true ` , the request and the
3126
+ response headers will never be squashed.
3127
+ All request headers will be sent multiple times if the header
3128
+ value was set to an array or set multiple times.
3129
+ All response headers will always be returned as a string if the
3130
+ header has been received once or as an array of strings if the header has
3131
+ been received multiple times.
3132
+ In both cases headers matching is case insensitive.
3075
3133
* ` hints ` {number} Optional [ ` dns.lookup() ` hints] [ ] .
3076
3134
* ` host ` {string} A domain name or IP address of the server to issue the
3077
3135
request to. ** Default:** ` 'localhost' ` .
0 commit comments