Expand description
Node http module: an HTTP/1.1 server built on top of net.
http.createServer(requestListener) returns a net.Server with an
http-specific per-connection hook. As bytes arrive on a connection (posted
by the socket reader thread and dispatched on the main thread by
net::on_socket_data → http::feed), we buffer them, parse complete
HTTP/1.1 requests, and for each one build an IncomingMessage (req) and a
ServerResponse (res) and call the user’s (req, res) listener on the main
thread. res.end serializes a valid HTTP/1.1 response and writes it straight
back to the socket via net::socket_write_id, keeping the connection alive.
Constants§
- CLIENT_
REQUEST_ METHODS - Instance methods of a client
ClientRequest(parent wires theClientRequesttag vianative_tag/instance_call). - MODULE_
METHODS httpmodule functions routed throughstdlib::call.
Functions§
- call
stdlib::callentry forhttp.<method>.- constant
- Non-function
httpmodule constants (http.METHODS,http.STATUS_CODES), reachable vianamespace_property→stdlib::constant. - construct
stdlib::constructentry forhttpclasses. Parent wires this in.- construct_
agent new http.Agent([options])— a minimal connection-pool holder. We open a fresh connection per request (no reuse), so the agent only carries its configuration for the JS side to read back.- create_
server - Build an HTTP server: a
net.Serverwhose per-connection hook wires up the request parser and remembers therequestListener. - drop_
conn - Discard an HTTP connection when its socket closes.
- feed
- Feed freshly received socket bytes into the HTTP parser. No-op for a socket
that is not an HTTP connection (plain
net). Runs on the main thread. - instance_
call - Instance dispatch for
IncomingMessage/ServerResponse(EventEmitter methods handled bynet’s shared emitter delegation viastdlib::instance_call). - request
http.request(options|url[, cb])/http.get(url|options[, cb]). Returns aClientRequest(aClientRequestemitter).getauto-sends via.end().- status_
table - The status-code → reason-phrase table shared by
STATUS_CODESand response serialization.