@@ -389,7 +389,7 @@ Example:
389
389
response.removeHeader("Content-Encoding");
390
390
391
391
392
- ### response.write(chunk[ , encoding] )
392
+ ### response.write(chunk[ , encoding] [ , callback ] )
393
393
394
394
If this method is called and [ response.writeHead()] [ ] has not been called,
395
395
it will switch to implicit header mode and flush the implicit headers.
@@ -399,7 +399,8 @@ be called multiple times to provide successive parts of the body.
399
399
400
400
` chunk ` can be a string or a buffer. If ` chunk ` is a string,
401
401
the second parameter specifies how to encode it into a byte stream.
402
- By default the ` encoding ` is ` 'utf8' ` .
402
+ By default the ` encoding ` is ` 'utf8' ` . The last parameter ` callback `
403
+ will be called when this chunk of data is flushed.
403
404
404
405
** Note** : This is the raw HTTP body and has nothing to do with
405
406
higher-level multi-part body encodings that may be used.
@@ -433,15 +434,15 @@ emit trailers, with a list of the header fields in its value. E.g.,
433
434
response.end();
434
435
435
436
436
- ### response.end([ data] [ , encoding ] )
437
+ ### response.end([ data] [ , encoding ] [ , callback ] )
437
438
438
439
This method signals to the server that all of the response headers and body
439
440
have been sent; that server should consider this message complete.
440
441
The method, ` response.end() ` , MUST be called on each
441
442
response.
442
443
443
- If ` data ` is specified, it is equivalent to calling ` response.write(data, encoding) `
444
- followed by ` response.end() ` .
444
+ If ` data ` is specified, it is equivalent to calling
445
+ ` response.write(data, encoding) ` followed by ` response.end(callback ) ` .
445
446
446
447
447
448
## http.request(options[ , callback] )
@@ -864,7 +865,7 @@ That's usually what you want (it saves a TCP round-trip) but not when the first
864
865
data isn't sent until possibly much later. ` request.flush() ` lets you bypass
865
866
the optimization and kickstart the request.
866
867
867
- ### request.write(chunk[ , encoding] )
868
+ ### request.write(chunk[ , encoding] [ , callback ] )
868
869
869
870
Sends a chunk of the body. By calling this method
870
871
many times, the user can stream a request body to a
@@ -877,15 +878,17 @@ The `chunk` argument should be a [Buffer][] or a string.
877
878
The ` encoding ` argument is optional and only applies when ` chunk ` is a string.
878
879
Defaults to ` 'utf8' ` .
879
880
881
+ The ` callback ` argument is optional and will be called when this chunk of data
882
+ is flushed.
880
883
881
- ### request.end([ data] [ , encoding ] )
884
+ ### request.end([ data] [ , encoding ] [ , callback ] )
882
885
883
886
Finishes sending the request. If any parts of the body are
884
887
unsent, it will flush them to the stream. If the request is
885
888
chunked, this will send the terminating ` '0\r\n\r\n' ` .
886
889
887
890
If ` data ` is specified, it is equivalent to calling
888
- ` request.write(data, encoding) ` followed by ` request.end() ` .
891
+ ` request.write(data, encoding) ` followed by ` request.end(callback ) ` .
889
892
890
893
### request.abort()
891
894
0 commit comments