8.16.0.1
9 Internals
Warning: This section describes internal implementation details that may change without warning. Contact the author before relying on this module.
(require http123/internal) | package: http123-lib |
|
Interface of objects that can implement the basic client operation of submitting
a request. The method async-request in http-client<%> is implemented by
forwarding it to an object implementing this interface (usually an instance of
http-connection-manager%).
method
(send a-http-client-base async-request req)
→ (evt/c (-> (is-a?/c response<%>))) req : request? Sends the request req and returns an event that becomes ready when the server either sends a response or when an error occurs. See also async-request.
| ||
superclass: object% | ||
|
Handles a request by creating connections (http-connection%) based on
the request’s location.
constructor
(new http-connection-manager% [ [ssl ssl] [custodian custodian]]) → (is-a?/c http-connection-manager%) ssl : (or/c 'secure 'auto ssl-client-context?) = 'secure custodian : custodian? = (current-custodian)
method
(send a-http-connection-manager get-connection loc)
→ (is-a?/c http-connection%) loc : ok-http-url? Returns the existing connection to the server specified by loc, or creates a new connection using open-connection if none exists yet. Connections are identified by the triple consisting of the location’s host, port, and scheme (https vs http).
method
(send a-http-connection-manager open-connection host port https?) → (is-a?/c http-connection%) host : string? port : (integer-in 1 (sub1 (expt 2 16))) https? : boolean? Creates a new connection to the server at host:port, using SSL/TLS if https? is true.
method
(send a-http-connection-manager async-request req)
→ (evt/c (-> (is-a?/c response<%>))) req : request? Equivalent to
(send (send a-http-connection-manager get-connection (request-url req)) async-request req)
| ||
superclass: object% | ||
|
Represents a connection to a specific server. A connection can be open or
closed; if a request is made to a closed connection, it is automatically
reopened by creating a new actual connection.
constructor
(new http-connection% [host host] [port port] [ssl ssl] [ [protocols protocols]] [custodian custodian]) → (is-a?/c http-connection%) host : string? port : (integer-in 1 (sub1 (expt 2 16))) ssl : (or/c #f 'secure 'auto ssl-client-context?) protocols : (listof symbol?) = '(http/2 http/1.1) custodian : custodian?
method
(send a-http-connection get-actual-connection [connect?])
→ http-actual-connection? connect? : boolean? = #t Gets the existing actual connection to the server. If none currently exists, one is created using open-actual-connection if connect? is true, or #f is returned otherwise.
method
(send a-http-connection open-actual-connection)
→ (is-a?/c http-actual-connection<%>) Creates a new actual connection to the server.
method
(send a-http-connection make-http1-connection)
→ (is-a?/c http-actual-connection<%>) Creates an actual connection implementing the HTTP/1.1 protocol.
method
(send a-http-connection make-http2-connection)
→ (is-a?/c http-actual-connection<%>) Creates an actual connection implementing the HTTP/2 protocol.Closes the current actual connection, if one exists.
method
(send a-http-connection async-request req)
→ (evt/c (-> (is-a?/c response<%>))) req : request? Submits the request to (get-actual-connection) using open-request. If the request submission fails, the current actual connection is abandoned and the request is retried with a new actual connection. If it fails too many times, an exception is raised.
|
Represents an actual communication channel to a server.
Marks the actual connection as closed. It no longer accepts new requests, but it continues to receive responses until the server hangs up.
method
(send a-http-actual-connection open-request req)
→ (or/c #f (evt/c (-> (is-a?/c response<%>)))) req : request? Submits the request to the server and returns an event, or returns #f if the submission failed (for example, if the connection was concurrently closed).Returns #t if the connection is still fully open—that is, new requests can be sent to the server— or #f if the connection is closed or half-open.