GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — doc: improve http.request documentation · nodejs/node@36ea472

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • doc/api
    • http.md
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎doc/api/http.md‎

Copy file name to clipboardExpand all lines: doc/api/http.md
+43Lines changed: 43 additions & 0 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -1880,6 +1880,49 @@ const req = http.request(options, (res) => {
18801880
});
18811881
```
18821882

1883+
In a successful request, the following events will be emitted in the following
1884+
order:
1885+
1886+
* `socket`
1887+
* `response`
1888+
* `data` any number of times, on the `res` object
1889+
(`data` will not be emitted at all if the response body is empty, for
1890+
instance, in most redirects)
1891+
* `end` on the `res` object
1892+
* `close`
1893+
1894+
In the case of a connection error, the following events will be emitted:
1895+
1896+
* `socket`
1897+
* `error`
1898+
* `close`
1899+
1900+
If `req.abort()` is called before the connection succeeds, the following events
1901+
will be emitted in the following order:
1902+
1903+
* `socket`
1904+
* (`req.abort()` called here)
1905+
* `abort`
1906+
* `close`
1907+
* `error` with an error with message `Error: socket hang up` and code
1908+
`ECONNRESET`
1909+
1910+
If `req.abort()` is called after the response is received, the following events
1911+
will be emitted in the following order:
1912+
1913+
* `socket`
1914+
* `response`
1915+
* `data` any number of times, on the `res` object
1916+
* (`req.abort()` called here)
1917+
* `abort`
1918+
* `close`
1919+
* `aborted` on the `res` object
1920+
* `end` on the `res` object
1921+
* `close` on the `res` object
1922+
1923+
Note that setting the `timeout` option or using the `setTimeout` function will
1924+
not abort the request or do anything besides add a `timeout` event.
1925+
18831926
[`'checkContinue'`]: #http_event_checkcontinue
18841927
[`'request'`]: #http_event_request
18851928
[`'response'`]: #http_event_response

0 commit comments

Comments
0 (0)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.