@@ -231,6 +231,61 @@ class HttpDuplex extends EventEmitter {
231
231
get writable ( ) {
232
232
return this . res . writable ;
233
233
}
234
+
235
+ /**
236
+ * Sends a response header to the client request. Must only be called one time and before calling response.end().
237
+ * @method writeHead
238
+ * @alias HttpDuplex.writeHead
239
+ * @memberof HttpDuplex
240
+ * @param {number } statusCode 3-digit HTTP status code, like 404
241
+ * @param {string } [statusMessage] An optional human readable status message to send with the status code
242
+ * @param {object } [headers] An object containing the response headers to send
243
+ * @returns {this }
244
+ * @see {@link https://nodejs.org/api/http.html#http_response_writehead_statuscode_statusmessage_headers|response.writeHead }
245
+ * @example var content = 'Under Construction...';
246
+ * response.writeHead(200, {
247
+ * 'Content-Length': Buffer.byteLength(content),
248
+ * 'Content-Type': 'text/plain'
249
+ * });
250
+ * response.end(content);
251
+ */
252
+ writeHead ( statusCode , statusMessage , headers ) {
253
+ this . res . writeHead ( statusCode , statusMessage , headers ) ;
254
+ return this ;
255
+ }
256
+
257
+ /**
258
+ * Buffers written data in memory. This data will be flushed when either the uncork or end methods are called.
259
+ * @method cork
260
+ * @alias HttpDuplex.cork
261
+ * @memberof HttpDuplex
262
+ * @returns {this }
263
+ * @see uncork
264
+ * @see {@link https://nodejs.org/api/stream.html#stream_writable_cork|stream.Writeable.cork }
265
+ * @example
266
+ * request.cork();
267
+ * request.write('buffer data ');
268
+ * request.write('before sending ');
269
+ * request.uncork();
270
+ */
271
+ cork ( ) {
272
+ this . res . connection . cork ( ) ;
273
+ return this ;
274
+ }
275
+
276
+ /**
277
+ * Flushes all data buffered since cork() was called.
278
+ * @method uncork
279
+ * @alias HttpDuplex.cork
280
+ * @memberof HttpDuplex
281
+ * @returns {this }
282
+ * @see cork
283
+ * @see {@link https://nodejs.org/api/stream.html#stream_writable_uncork|stream.Writeable.uncork }
284
+ */
285
+ uncork ( ) {
286
+ this . res . connection . uncork ( ) ;
287
+ return this ;
288
+ }
234
289
}
235
290
236
291
// proxy request methods
@@ -242,7 +297,7 @@ class HttpDuplex extends EventEmitter {
242
297
243
298
// proxy respone methods
244
299
[
245
- 'cork' , 'uncork' , ' setDefaultEncoding', 'write' , 'end' , 'flush' , 'writeHeader' , 'writeHead ', 'writeContinue' ,
300
+ 'setDefaultEncoding' , 'write' , 'end' , 'flush' , 'writeHeader' , 'writeContinue' ,
246
301
'setHeader' , 'getHeader' , 'removeHeader' , 'addTrailers'
247
302
] . forEach ( function ( name ) {
248
303
HttpDuplex . prototype [ name ] = function ( ) {
@@ -334,20 +389,6 @@ module.exports = HttpDuplex;
334
389
* @see {@link https://nodejs.org/api/http.html#http_response_addtrailers_headers|response.addTrailers }
335
390
*/
336
391
337
- /**
338
- * Buffers written data in memory. This data will be flushed when either the uncork or end methods are called.
339
- * @method cork
340
- * @alias HttpDuplex.cork
341
- * @memberof HttpDuplex
342
- * @see uncork
343
- * @see {@link https://nodejs.org/api/stream.html#stream_writable_cork|stream.Writeable.cork }
344
- * @example
345
- * request.cork();
346
- * request.write('buffer data ');
347
- * request.write('before sending ');
348
- * request.uncork();
349
- */
350
-
351
392
/**
352
393
* Tells the server the response headers and body have been sent and that the message should be considered complete.
353
394
* This MUST be called on every response.
@@ -439,15 +480,6 @@ module.exports = HttpDuplex;
439
480
* request.setHeader('Set-Cookie', ['type=auth', 'language=javascript']);
440
481
*/
441
482
442
- /**
443
- * Flushes all data buffered since cork() was called.
444
- * @method uncork
445
- * @alias HttpDuplex.cork
446
- * @memberof HttpDuplex
447
- * @see cork
448
- * @see {@link https://nodejs.org/api/stream.html#stream_writable_uncork|stream.Writeable.uncork }
449
- */
450
-
451
483
/**
452
484
* Sends a chunk of the response body. This method may be called multiple times to provide successive parts of the
453
485
* body.
@@ -476,23 +508,6 @@ module.exports = HttpDuplex;
476
508
* {@link https://nodejs.org/api/http.html#http_event_checkcontinue|http.Server/checkContinue }
477
509
*/
478
510
479
- /**
480
- * Sends a response header to the client request. Must only be called one time and before calling response.end().
481
- * @method writeHead
482
- * @alias HttpDuplex.writeHead
483
- * @memberof HttpDuplex
484
- * @param {Number } statusCode 3-digit HTTP status code, like 404
485
- * @param {String } [statusMessage] An optional human readable status message to send with the status code
486
- * @param {Object } [headers] An object containing the response headers to send
487
- * @see {@link https://nodejs.org/api/http.html#http_response_writehead_statuscode_statusmessage_headers|response.writeHead }
488
- * @example var content = 'Under Construction...';
489
- * response.writeHead(200, {
490
- * 'Content-Length': Buffer.byteLength(content),
491
- * 'Content-Type': 'text/plain'
492
- * });
493
- * response.end(content);
494
- */
495
-
496
511
/**
497
512
* __Warning:__ This has been deprecated in node, __don't__ use it. Any apis that require this funtion should be
498
513
* updated to use writeHead insted.
0 commit comments