HTTP Networking APIs
The HTTP interfaces are built to make it easier to use traditionally difficult protocol features. By never buffering complete requests or responses, users can stream data instead, making data transmission more efficient and flexible.
- Source:
- See:
Classes
Members
(static, constant) METHODS :Array.<string>
A list of the HTTP methods that are supported by the parser.
Type:
-
Array.<string>
(static, constant) STATUS_CODES :Array.<string>
A collection of all the standard HTTP response status codes.
Type:
-
Array.<string>
Methods
(static) createServer(onRequestopt) → {Server}
Creates a new HTTP server.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
onRequest |
function
|
<optional> |
A function that is called whenever the server receives a HTTP request. |
Returns:
- Type:
-
Server
Representing the newly created HTTP server.
(static) request(url, optionsopt) → {Promise.<IncomingResponse>}
Performs an HTTP request.
Parameters:
Name | Type | Attributes | Description | ||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
url |
string
|
The URL to which the HTTP request is sent. |
|||||||||||||||||||||||||||||
options |
Object
|
<optional> |
Configuration options for the HTTP request.
|
Returns:
- Type:
-
Promise.<IncomingResponse>
Containing the HTTP response.
Type Definitions
Connection
An object representing an HTTP connection.
Properties:
Name | Type | Description |
---|---|---|
request |
ServerRequest
|
The incoming HTTP request. |
response |
ServerResponse
|
The HTTP response that will be sent by the server. |