Trim: docs/api/net.md
This commit is contained in:
parent
721924b749
commit
836cd017a9
1 changed files with 18 additions and 18 deletions
|
@ -3,7 +3,7 @@
|
|||
> Issue HTTP/HTTPS requests using Chromium's native networking library
|
||||
|
||||
The `net` module is a client-side API for issuing HTTP(S) requests. It is
|
||||
similar to the [HTTP](https://nodejs.org/api/http.html) and
|
||||
similar to the [HTTP](https://nodejs.org/api/http.html) and
|
||||
[HTTPS](https://nodejs.org/api/https.html) modules of Node.js but uses
|
||||
Chromium's native networking library instead of the Node.js implementation,
|
||||
offering better support for web proxies.
|
||||
|
@ -12,12 +12,12 @@ The following is a non-exhaustive list of why you may consider using the `net`
|
|||
module instead of the native Node.js modules:
|
||||
|
||||
* Automatic management of system proxy configuration, support of the wpad
|
||||
protocol and proxy pac configuration files.
|
||||
protocol and proxy pac configuration files.
|
||||
* Automatic tunneling of HTTPS requests.
|
||||
* Support for authenticating proxies using basic, digest, NTLM, Kerberos or
|
||||
negotiate authentication schemes.
|
||||
negotiate authentication schemes.
|
||||
* Support for traffic monitoring proxies: Fiddler-like proxies used for access
|
||||
control and monitoring.
|
||||
control and monitoring.
|
||||
|
||||
The `net` module API has been specifically designed to mimic, as closely as
|
||||
possible, the familiar Node.js API. The API components including classes,
|
||||
|
@ -78,22 +78,22 @@ interface and is therefore an [EventEmitter](https://nodejs.org/api/events.html#
|
|||
### `new ClientRequest(options)`
|
||||
|
||||
* `options` (Object | String) - If `options` is a String, it is interpreted as
|
||||
the request URL. If it is an object, it is expected to fully specify an HTTP request via the
|
||||
following properties:
|
||||
the request URL. If it is an object, it is expected to fully specify an HTTP
|
||||
request via the following properties:
|
||||
* `method` String (optional) - The HTTP request method. Defaults to the GET
|
||||
method.
|
||||
method.
|
||||
* `url` String (optional) - The request URL. Must be provided in the absolute
|
||||
form with the protocol scheme specified as http or https.
|
||||
form with the protocol scheme specified as http or https.
|
||||
* `session` Object (optional) - The [`Session`](session.md) instance with
|
||||
which the request is associated.
|
||||
which the request is associated.
|
||||
* `partition` String (optional) - The name of the [`partition`](session.md)
|
||||
with which the request is associated. Defaults to the empty string. The
|
||||
`session` option prevails on `partition`. Thus if a `session` is explicitly
|
||||
specified, `partition` is ignored.
|
||||
with which the request is associated. Defaults to the empty string. The
|
||||
`session` option prevails on `partition`. Thus if a `session` is explicitly
|
||||
specified, `partition` is ignored.
|
||||
* `protocol` String (optional) - The protocol scheme in the form 'scheme:'.
|
||||
Currently supported values are 'http:' or 'https:'. Defaults to 'http:'.
|
||||
Currently supported values are 'http:' or 'https:'. Defaults to 'http:'.
|
||||
* `host` String (optional) - The server host provided as a concatenation of
|
||||
the hostname and the port number 'hostname:port'
|
||||
the hostname and the port number 'hostname:port'
|
||||
* `hostname` String (optional) - The server host name.
|
||||
* `port` Integer (optional) - The server's listening port number.
|
||||
* `path` String (optional) - The path part of the request URL.
|
||||
|
@ -146,6 +146,7 @@ request.on('login', (authInfo, callback) => {
|
|||
callback('username', 'password')
|
||||
})
|
||||
```
|
||||
|
||||
Providing empty credentials will cancel the request and report an authentication
|
||||
error on the response object:
|
||||
|
||||
|
@ -228,10 +229,10 @@ before first write. Trying to call it after the first write will throw an error.
|
|||
#### `request.write(chunk[, encoding][, callback])`
|
||||
|
||||
* `chunk` (String | Buffer) - A chunk of the request body's data. If it is a
|
||||
string, it is converted into a Buffer using the specified encoding.
|
||||
string, it is converted into a Buffer using the specified encoding.
|
||||
* `encoding` String (optional) - Used to convert string chunks into Buffer
|
||||
objects. Defaults to 'utf-8'.
|
||||
* `callback` Function (optional) - Called after the write operation ends.
|
||||
objects. Defaults to 'utf-8'.
|
||||
* `callback` Function (optional) - Called after the write operation ends.
|
||||
|
||||
`callback` is essentially a dummy function introduced in the purpose of keeping
|
||||
similarity with the Node.js API. It is called asynchronously in the next tick
|
||||
|
@ -259,7 +260,6 @@ Cancels an ongoing HTTP transaction. If the request has already emitted the
|
|||
event will emit `abort` and `close` events. Additionally, if there is an ongoing
|
||||
response object,it will emit the `aborted` event.
|
||||
|
||||
|
||||
## Class: IncomingMessage
|
||||
|
||||
> Handle responses to HTTP/HTTPS requests.
|
||||
|
|
Loading…
Reference in a new issue