doc: http: properly document callback argument
authorNikolai Vavilov <vvnicholas@gmail.com>
Thu, 28 Nov 2013 20:25:30 +0000 (22:25 +0200)
committerBen Noordhuis <info@bnoordhuis.nl>
Thu, 28 Nov 2013 21:31:11 +0000 (22:31 +0100)
doc/api/http.markdown

index 88f313d..882ea0f 100644 (file)
@@ -395,7 +395,7 @@ If `data` is specified, it is equivalent to calling `response.write(data, encodi
 followed by `response.end()`.
 
 
-## http.request(options, callback)
+## http.request(options, [callback])
 
 Node maintains several connections per server to make HTTP requests.
 This function allows one to transparently issue requests.
@@ -424,6 +424,9 @@ Options:
  - `false`: opts out of connection pooling with an Agent, defaults request to
    `Connection: close`.
 
+The optional `callback` parameter will be added as a one time listener for
+the ['response'][] event.
+
 `http.request()` returns an instance of the [http.ClientRequest][]
 class. The `ClientRequest` instance is a writable stream. If one needs to
 upload a file with a POST request, then write to the `ClientRequest` object.
@@ -478,7 +481,7 @@ There are a few special headers that should be noted.
 * Sending an Authorization header will override using the `auth` option
   to compute basic authentication.
 
-## http.get(options, callback)
+## http.get(options, [callback])
 
 Since most requests are GET requests without bodies, Node provides this
 convenience method. The only difference between this method and `http.request()`
@@ -867,6 +870,7 @@ authentication details.
 
 ['checkContinue']: #http_event_checkcontinue
 ['listening']: net.html#net_event_listening
+['response']: #http_event_response
 [Agent]: #http_class_http_agent
 [Buffer]: buffer.html#buffer_buffer
 [EventEmitter]: events.html#events_class_events_eventemitter