Skip to main content

Module https

Module https 

Source
Expand description

Node https module: HTTP/1.1 over real TLS.

Server: https.createServer(options, requestListener) builds a tls server (real rustls handshake, see tls.rs) whose per-connection hook attaches an HTTP/1.1 request parser. As decrypted bytes arrive (tls::on_socket_data → https::feed) we parse complete requests, build an IncomingMessage (req) and a response object (res), and call the user’s (req, res) listener. res.end serializes an HTTP/1.1 response and writes it back through the TLS channel via tls::socket_write.

Client: https.request(options[, cb]) / https.get(url[, cb]) open a blocking TLS connection on a background thread, write the request, read the full response (the request forces Connection: close, so read-to-EOF is reliable), parse it into an IncomingMessage, and fire cb(res) on the main thread.

The HTTP/1.1 request parser and response serializer here are minimal reimplementations of the private logic in http.rs (parse_request, serialize_response). They are duplicated because that logic writes to net sockets via net::socket_write_id, whereas an https response must go through the TLS write channel. If http::parse_request/ParsedReq/serialize_response/ ResState were made pub (and response writing were sink-agnostic), https could delegate to them instead.

Constants§

CLIENT_REQUEST_METHODS
MODULE_METHODS
https module functions routed through stdlib::call.
RESPONSE_METHODS
Instance method names for this module’s @@native tags (property reads that yield a bound method), exposed to stdlib::instance_has_method.

Functions§

call
stdlib::call entry for https.<method>.
constant
https.Agent / https.globalAgent: a minimal stub. node-js opens a fresh connection per request (no pooling / keep-alive reuse), so an Agent carries no behavior beyond being a constructible/inspectable object.
create_server
drop_conn
Discard an https connection when its TLS socket closes (called by tls).
feed
Feed decrypted bytes into the https request parser. No-op for a socket that is not an https connection. Runs on the main thread.
instance_call
request
https.request(options[, cb]) / https.get(url|options[, cb]). Returns a ClientRequest (a HTTPSClientRequest emitter). get auto-sends.