@@ -587,13 +587,24 @@ added: v1.6.0
587587-->
588588
589589* ` name ` {string}
590- * Returns: {string }
590+ * Returns: {any }
591591
592592Reads out a header on the request. Note that the name is case insensitive.
593+ The type of the return value depends on the arguments provided to
594+ [ ` request.setHeader() ` ] [ ] .
593595
594596Example:
595597``` js
598+ request .setHeader (' content-type' , ' text/html' );
599+ request .setHeader (' Content-Length' , Buffer .byteLength (body));
600+ request .setHeader (' Set-Cookie' , [' type=ninja' , ' language=javascript' ]);
596601const contentType = request .getHeader (' Content-Type' );
602+ // contentType is 'text/html'
603+ const contentLength = request .getHeader (' Content-Length' );
604+ // contentLength is of type number
605+ const setCookie = request .getHeader (' set-cookie' );
606+ // setCookie is of type string[]
607+
597608```
598609
599610### request.removeHeader(name)
@@ -616,11 +627,14 @@ added: v1.6.0
616627-->
617628
618629* ` name ` {string}
619- * ` value ` {string }
630+ * ` value ` {any }
620631
621632Sets a single header value for headers object. If this header already exists in
622633the to-be-sent headers, its value will be replaced. Use an array of strings
623- here to send multiple headers with the same name.
634+ here to send multiple headers with the same name. Non-string values will be
635+ stored without modification. Therefore, [ ` request.getHeader() ` ] [ ] may return
636+ non-string values. However, the non-string values will be converted to strings
637+ for network transmission.
624638
625639Example:
626640``` js
@@ -1085,15 +1099,24 @@ added: v0.4.0
10851099-->
10861100
10871101* ` name ` {string}
1088- * Returns: {string }
1102+ * Returns: {any }
10891103
10901104Reads out a header that's already been queued but not sent to the client.
1091- Note that the name is case insensitive.
1105+ Note that the name is case insensitive. The type of the return value depends
1106+ on the arguments provided to [ ` response.setHeader() ` ] [ ] .
10921107
10931108Example:
10941109
10951110``` js
1111+ response .setHeader (' Content-Type' , ' text/html' );
1112+ response .setHeader (' Content-Length' , Buffer .byteLength (body));
1113+ response .setHeader (' Set-Cookie' , [' type=ninja' , ' language=javascript' ]);
10961114const contentType = response .getHeader (' content-type' );
1115+ // contentType is 'text/html'
1116+ const contentLength = response .getHeader (' Content-Length' );
1117+ // contentLength is of type number
1118+ const setCookie = response .getHeader (' set-cookie' );
1119+ // setCookie is of type string[]
10971120```
10981121
10991122### response.getHeaderNames()
@@ -1204,11 +1227,14 @@ added: v0.4.0
12041227-->
12051228
12061229* ` name ` {string}
1207- * ` value ` {string | string [ ] }
1230+ * ` value ` {any }
12081231
12091232Sets a single header value for implicit headers. If this header already exists
12101233in the to-be-sent headers, its value will be replaced. Use an array of strings
1211- here to send multiple headers with the same name.
1234+ here to send multiple headers with the same name. Non-string values will be
1235+ stored without modification. Therefore, [ ` response.getHeader() ` ] [ ] may return
1236+ non-string values. However, the non-string values will be converted to strings
1237+ for network transmission.
12121238
12131239Example:
12141240
@@ -2013,11 +2039,14 @@ not abort the request or do anything besides add a `'timeout'` event.
20132039[ `net.createConnection()` ] : net.html#net_net_createconnection_options_connectlistener
20142040[ `removeHeader(name)` ] : #http_request_removeheader_name
20152041[ `request.end()` ] : #http_request_end_data_encoding_callback
2042+ [ `request.getHeader()` ] : #http_request_getheader_name
2043+ [ `request.setHeader()` ] : #http_request_setheader_name_value
20162044[ `request.setTimeout()` ] : #http_request_settimeout_timeout_callback
20172045[ `request.socket` ] : #http_request_socket
20182046[ `request.socket.getPeerCertificate()` ] : tls.html#tls_tlssocket_getpeercertificate_detailed
20192047[ `request.write(data, encoding)` ] : #http_request_write_chunk_encoding_callback
20202048[ `response.end()` ] : #http_response_end_data_encoding_callback
2049+ [ `response.getHeader()` ] : #http_response_getheader_name
20212050[ `response.setHeader()` ] : #http_response_setheader_name_value
20222051[ `response.socket` ] : #http_response_socket
20232052[ `response.write()` ] : #http_response_write_chunk_encoding_callback
0 commit comments