Documenting net module: various fixes.
This commit is contained in:
parent
0d82fbcf37
commit
3b620b8c0c
1 changed files with 20 additions and 16 deletions
|
@ -10,14 +10,14 @@ Following is a non-exhaustive list of why you may need to use the `net` module i
|
||||||
* Support for authenticating proxies using basic, digest, NTLM, Kerberos or negotiate authentication schemes.
|
* Support for authenticating proxies using basic, digest, NTLM, Kerberos or negotiate authentication schemes.
|
||||||
* Support for traffic monitoring proxies: Fiddler-like proxies used for access control and monitoring.
|
* Support for traffic monitoring proxies: Fiddler-like proxies used for access control and monitoring.
|
||||||
|
|
||||||
The following example quickly shows how the net API mgiht be used:
|
The following example quickly shows how the `net` API mgiht be used:
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
const {app} = require('electron')
|
const {app} = require('electron')
|
||||||
|
|
||||||
app.on('ready', () => {
|
app.on('ready', () => {
|
||||||
const {net} = require('electron')
|
const {net} = require('electron')
|
||||||
const request = net.request('https://github.com')
|
const request = net.request('https://github.com')
|
||||||
request.on('response', (response) => {
|
request.on('response', (response) => {
|
||||||
console.log(`STATUS: ${response.statusCode}`);
|
console.log(`STATUS: ${response.statusCode}`);
|
||||||
console.log(`HEADERS: ${JSON.stringify(response.headers)}`);
|
console.log(`HEADERS: ${JSON.stringify(response.headers)}`);
|
||||||
response.on('data', (chunk) => {
|
response.on('data', (chunk) => {
|
||||||
|
@ -26,8 +26,8 @@ request.on('response', (response) => {
|
||||||
response.on('end', () => {
|
response.on('end', () => {
|
||||||
console.log('No more data in response.');
|
console.log('No more data in response.');
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
request.end()
|
request.end()
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ Create a `ClientRequest` instance using the provided `options` object.
|
||||||
|
|
||||||
## Class: ClientRequest
|
## Class: ClientRequest
|
||||||
|
|
||||||
`ClientRequest` is a [Writable Stream](https://nodejs.org/api/stream.html#stream_writable_streams).
|
`ClientRequest` implements the [Writable Stream](https://nodejs.org/api/stream.html#stream_writable_streams) interface.
|
||||||
|
|
||||||
### `new ClientRequest(options)`
|
### `new ClientRequest(options)`
|
||||||
|
|
||||||
|
@ -201,7 +201,11 @@ A String representing the HTTP status message.
|
||||||
|
|
||||||
#### `response.headers`
|
#### `response.headers`
|
||||||
|
|
||||||
An Object representing the response HTTP headers.
|
An Object representing the response HTTP headers. The `headers` object is formatted as follows:
|
||||||
|
|
||||||
|
* All header names are lowercased.
|
||||||
|
* Each header name produces an array-valued property on the headers object.
|
||||||
|
* Each header value is pushed into the array associated with its header name.
|
||||||
|
|
||||||
#### `response.httpVersion`
|
#### `response.httpVersion`
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue