@@ -286,9 +286,9 @@ added: v0.1.17
286286
287287This object is created internally and returned from [ ` http.request() ` ] [ ] . It
288288represents an _ in-progress_ request whose header has already been queued. The
289- header is still mutable using the ` setHeader(name, value) ` , ` getHeader(name) ` ,
290- ` removeHeader(name) ` API. The actual header will be sent along with the first
291- data chunk or when calling [ ` request.end() ` ] [ ] .
289+ header is still mutable using the [ ` setHeader(name, value) ` ] [ ] ,
290+ [ ` getHeader(name) ` ] [ ] , [ ` removeHeader(name) ` ] [ ] API. The actual header will
291+ be sent along with the first data chunk or when calling [ ` request.end() ` ] [ ] .
292292
293293To get the response, add a listener for [ ` 'response' ` ] [ ] to the request object.
294294[ ` 'response' ` ] [ ] will be emitted from the request object when the response
@@ -552,6 +552,58 @@ That's usually desired (it saves a TCP round-trip), but not when the first
552552data is not sent until possibly much later. ` request.flushHeaders() ` bypasses
553553the optimization and kickstarts the request.
554554
555+ ### request.getHeader(name)
556+ <!-- YAML
557+ added: v1.6.0
558+ -->
559+
560+ * ` name ` {string}
561+ * Returns: {string}
562+
563+ Reads out a header on the request. Note that the name is case insensitive.
564+
565+ Example:
566+ ``` js
567+ const contentType = request .getHeader (' Content-Type' );
568+ ```
569+
570+ ### request.removeHeader(name)
571+ <!-- YAML
572+ added: v1.6.0
573+ -->
574+
575+ * ` name ` {string}
576+
577+ Removes a header that's already defined into headers object.
578+
579+ Example:
580+ ``` js
581+ request .removeHeader (' Content-Type' );
582+ ```
583+
584+ ### request.setHeader(name, value)
585+ <!-- YAML
586+ added: v1.6.0
587+ -->
588+
589+ * ` name ` {string}
590+ * ` value ` {string}
591+
592+ Sets a single header value for headers object. If this header already exists in
593+ the to-be-sent headers, its value will be replaced. Use an array of strings
594+ here to send multiple headers with the same name.
595+
596+ Example:
597+ ``` js
598+ request .setHeader (' Content-Type' , ' application/json' );
599+ ```
600+
601+ or
602+
603+ ``` js
604+ request .setHeader (' Set-Cookie' , [' type=ninja' , ' language=javascript' ]);
605+ ```
606+
555607### request.setNoDelay([ noDelay] )
556608<!-- YAML
557609added: v0.5.9
@@ -1904,6 +1956,7 @@ const req = http.request(options, (res) => {
19041956[ `agent.createConnection()` ] : #http_agent_createconnection_options_callback
19051957[ `agent.getName()` ] : #http_agent_getname_options
19061958[ `destroy()` ] : #http_agent_destroy
1959+ [ `getHeader(name)` ] : #requestgetheadername
19071960[ `http.Agent` ] : #http_class_http_agent
19081961[ `http.ClientRequest` ] : #http_class_http_clientrequest
19091962[ `http.IncomingMessage` ] : #http_class_http_incomingmessage
@@ -1918,6 +1971,7 @@ const req = http.request(options, (res) => {
19181971[ `net.Server` ] : net.html#net_class_net_server
19191972[ `net.Socket` ] : net.html#net_class_net_socket
19201973[ `net.createConnection()` ] : net.html#net_net_createconnection_options_connectlistener
1974+ [ `removeHeader(name)` ] : #requestremoveheadername
19211975[ `request.end()` ] : #http_request_end_data_encoding_callback
19221976[ `request.setTimeout()` ] : #http_request_settimeout_timeout_callback
19231977[ `request.socket` ] : #http_request_socket
@@ -1931,6 +1985,7 @@ const req = http.request(options, (res) => {
19311985[ `response.writeContinue()` ] : #http_response_writecontinue
19321986[ `response.writeHead()` ] : #http_response_writehead_statuscode_statusmessage_headers
19331987[ `server.timeout` ] : #http_server_timeout
1988+ [ `setHeader(name, value)` ] : #requestsetheadername-value
19341989[ `socket.setKeepAlive()` ] : net.html#net_socket_setkeepalive_enable_initialdelay
19351990[ `socket.setNoDelay()` ] : net.html#net_socket_setnodelay_nodelay
19361991[ `socket.setTimeout()` ] : net.html#net_socket_settimeout_timeout_callback
0 commit comments