protocol
http_transport_protocol
HTTP transport predicates for client connections and server listeners.
logtalk_load(http_socket_transport(loader))staticPublic predicates
open_listener/4
Opens a TCP listener on the given host and port using the given socket options. If Port is a variable, it is unified with the bound port number.
staticopen_listener(Host,Port,Listener,Options)open_listener(+atom,?integer,--compound,+list) - one_or_errorHost is not a valid listener host atom:type_error(atom,Host)Port is not a non-negative integer or a variable:domain_error(non_negative_integer,Port)Options is a variable or a partial list:instantiation_errorOptions is neither a variable nor a list:type_error(list,Options)Option of the list Options is neither a variable nor a compound term:type_error(compound,Option)Option of the list Options is a compound term but not a valid option:domain_error(option,Option)Options contains an invalid listener option:domain_error(http_process_transport_listener_option,Option)Options contains an invalid listener helper executable:domain_error(http_process_transport_listener_helper_executable,Executable)Options contains incompatible TCP listener options:domain_error(http_process_transport_listener_tcp_options,[listener_transport(tcp),temporary_tls_credentials(TemporaryTLSCredentialsPrefix)])Options contains incompatible TLS listener options:domain_error(http_process_transport_listener_tls_options,[tls_certificate_file(CertificateFile),tls_key_file(KeyFile)])resource_error(http_process_transport_temporary_tls_credentials)resource_error(http_process_transport_listener)close_listener/1
Closes a listener previously opened with open_listener/4.
staticclose_listener(Listener)close_listener(+compound) - one_or_errorListener is a variable:instantiation_errorListener is not an open listener handle for the transport implementation:domain_error(http_socket_transport_listener,Listener)Listener no longer exists for the transport implementation:existence_error(http_socket_transport_listener,Listener)request_listener_shutdown/1
Best-effort wakeup request for a listener accept loop opened with open_listener/4. This predicate does not close the listener but causes a blocked accept call to return portably when possible.
staticrequest_listener_shutdown(Listener)request_listener_shutdown(+compound) - one_or_errorListener is a variable:instantiation_errorListener is not an open listener handle for the transport implementation:domain_error(http_socket_transport_listener,Listener)Listener no longer exists for the transport implementation:existence_error(http_socket_transport_listener,Listener)open_connection/4
Opens a reusable client connection to the given host and port using the given socket options.
staticopen_connection(Host,Port,Connection,Options)open_connection(+atom,+integer,--compound,+list) - one_or_errorHost and Port are not a valid HTTP authority target:domain_error(http_target,authority(Host,Port))Options is a variable or a partial list:instantiation_errorOptions is neither a variable nor a list:type_error(list,Options)Option of the list Options is neither a variable nor a compound term:type_error(compound,Option)Option of the list Options is a compound term but not a valid option:domain_error(option,Option)Options contains an invalid connection option:domain_error(http_process_transport_connection_option,Option)resource_error(http_process_transport_connection)close_connection/1
Closes a reusable client connection previously opened with open_connection/4.
staticclose_connection(Connection)close_connection(+compound) - one_or_errorConnection is a variable:instantiation_errorConnection is not an open reusable client connection handle:domain_error(http_socket_transport_connection,Connection)connection_streams/3
Returns the binary input and output streams carried by a reusable client connection handle or by an upgraded WebSocket connection handle returned by serve_websocket_once/5.
staticconnection_streams(Connection,Input,Output)connection_streams(+compound,--stream,--stream) - one_or_errorConnection is a variable:instantiation_errorConnection is not an open reusable client or upgraded WebSocket connection handle:domain_error(http_socket_transport_connection,Connection)open_connection_pool/4
Opens a managed reusable connection pool for the given host and port.
staticopen_connection_pool(Host,Port,Pool,Options)open_connection_pool(+atom,+integer,--compound,+list) - one_or_errorHost and Port are not a valid HTTP authority target:domain_error(http_target,authority(Host,Port))Options is a variable or a partial list:instantiation_errorOptions is neither a variable nor a list:type_error(list,Options)Option of the list Options is neither a variable nor a compound term:type_error(compound,Option)Option of the list Options is a compound term but not a valid option:domain_error(option,Option)Options contains an invalid connection-pool option:domain_error(http_socket_transport_connection_pool_option,Option)Options contains an invalid process-backed connection-pool option:domain_error(http_process_transport_connection_pool_option,Option)Options contains incompatible connection-pool bounds:domain_error(http_socket_transport_connection_pool_options,[min_size(MinSize),max_size(MaxSize)])Options contains incompatible process-backed connection-pool bounds:domain_error(http_process_transport_connection_pool_options,[min_size(MinSize),max_size(MaxSize)])resource_error(http_socket_transport_connection_pool)resource_error(http_process_transport_connection)
Option
min_size(N): Pre-open N reusable client connections when creating the pool. The default is0.Option
max_size(N): Allow at most N managed client connections in the pool. The default is10.Option
connection_options(Options): Socket options passed toopen_connection/4when creating pooled connections. The default is[].
close_connection_pool/1
Closes a managed reusable connection pool and all currently available pooled connections. Throws if pooled exchanges are still in progress.
staticclose_connection_pool(Pool)close_connection_pool(+compound) - one_or_errorPool is a variable:instantiation_errorPool is not a valid managed connection-pool handle:domain_error(http_socket_transport_connection_pool,Pool)Pool no longer exists:existence_error(http_socket_transport_connection_pool,Pool)Pool cannot be closed while pooled exchanges remain active:permission_error(close,http_socket_transport_connection_pool,Pool)connection_pool_stats/2
Returns managed pool statistics as stats(Available, InUse, Total, MinSize, MaxSize).
staticconnection_pool_stats(Pool,Stats)connection_pool_stats(+compound,--compound) - one_or_errorPool is a variable:instantiation_errorPool is not a valid managed connection-pool handle:domain_error(http_socket_transport_connection_pool,Pool)Pool no longer exists:existence_error(http_socket_transport_connection_pool,Pool)exchange/3
Performs a single HTTP exchange on an open reusable client connection or by temporarily acquiring a pooled reusable client connection.
staticexchange(ConnectionOrPool,Request,Response)exchange(+compound,+compound,--compound) - one_or_errorConnectionOrPool is a variable:instantiation_errorConnectionOrPool is neither an open connection nor a managed connection-pool handle:domain_error(http_socket_transport_connection,ConnectionOrPool)ConnectionOrPool is not a valid managed connection-pool handle:domain_error(http_socket_transport_connection_pool,ConnectionOrPool)ConnectionOrPool no longer exists as a managed connection pool:existence_error(http_socket_transport_connection_pool,ConnectionOrPool)resource_error(http_socket_transport_connection_pool)Request is not a valid normalized HTTP request term:domain_error(http_request,Request)domain_error(http_response_stream,Error)exchange_sequence/3
Performs a sequence of HTTP exchanges on an open reusable client connection or by temporarily acquiring a pooled reusable client connection while HTTP persistence rules allow it.
staticexchange_sequence(ConnectionOrPool,Requests,Responses)exchange_sequence(+compound,++list(compound),--list(compound)) - one_or_errorConnectionOrPool is a variable:instantiation_errorConnectionOrPool is neither an open connection nor a managed connection-pool handle:domain_error(http_socket_transport_connection,ConnectionOrPool)ConnectionOrPool is not a valid managed connection-pool handle:domain_error(http_socket_transport_connection_pool,ConnectionOrPool)ConnectionOrPool no longer exists as a managed connection pool:existence_error(http_socket_transport_connection_pool,ConnectionOrPool)resource_error(http_socket_transport_connection_pool)Requests is not a list of normalized HTTP request terms:domain_error(http_request_sequence,Requests)domain_error(http_response_stream,Error)exchange/4
Opens a client socket connection to the given host and port, performs a single HTTP exchange, and closes the connection. When the request does not already specify connection handling, Connection: close is added automatically.
staticexchange(Host,Port,Request,Response)exchange(+atom,+integer,+compound,--compound) - one_or_errorHost and Port are not a valid HTTP authority target:domain_error(http_target,authority(Host,Port))resource_error(http_process_transport_connection)Request is not a valid normalized HTTP request term:domain_error(http_request,Request)domain_error(http_response_stream,Error)exchange/5
Opens a client socket connection to the given host and port using the given connection options, performs a single HTTP exchange, and closes the connection. When the request does not already specify connection handling, Connection: close is added automatically.
staticexchange(Host,Port,Request,Response,Options)exchange(+atom,+integer,+compound,--compound,+list) - one_or_errorHost and Port are not a valid HTTP authority target:domain_error(http_target,authority(Host,Port))Options is a variable or a partial list:instantiation_errorOptions is neither a variable nor a list:type_error(list,Options)Option of the list Options is neither a variable nor a compound term:type_error(compound,Option)Option of the list Options is a compound term but not a valid option:domain_error(option,Option)Options contains an invalid connection option:domain_error(http_process_transport_connection_option,Option)resource_error(http_process_transport_connection)Request is not a valid normalized HTTP request term:domain_error(http_request,Request)domain_error(http_response_stream,Error)exchange_sequence/4
Opens a client socket connection to the given host and port, performs a sequence of HTTP exchanges on that connection, and closes the connection. When the last request does not already specify connection handling, Connection: close is added automatically to that final request.
staticexchange_sequence(Host,Port,Requests,Responses)exchange_sequence(+atom,+integer,++list(compound),--list(compound)) - one_or_errorHost and Port are not a valid HTTP authority target:domain_error(http_target,authority(Host,Port))resource_error(http_process_transport_connection)Requests is not a list of normalized HTTP request terms:domain_error(http_request_sequence,Requests)domain_error(http_response_stream,Error)serve_once/3
Accepts one incoming socket connection on the given server socket, serves that connection using the http_server_core library, closes the streams, and returns client information.
staticserve_once(ServerSocket,Handler,ClientInfo)serve_once(+compound,+object_identifier,--compound) - one_or_errorHandler does not conform to the HTTP handler protocol:domain_error(http_handler_protocol,Handler)domain_error(http_response_stream,Error)serve_websocket_once/5
Accepts one incoming socket connection on the given listener, serves exactly one WebSocket opening handshake using the given handler, and on success returns an upgraded connection handle that remains open together with the handshake response and client information. Rejected or malformed handshakes are written to the stream, the accepted streams are closed, and the predicate throws.
staticserve_websocket_once(Listener,Handler,Connection,Response,ClientInfo)serve_websocket_once(+compound,+object_identifier,--compound,--compound,--compound) - one_or_errorHandler does not conform to the HTTP handler protocol:domain_error(http_handler_protocol,Handler)existence_error(http_socket_transport_websocket_request,end_of_file)domain_error(http_socket_transport_websocket_response,Response)domain_error(http_response_stream,Error)serve_listener/4
Accepts and serves Count incoming connections on the given listener, returning the accepted client information terms in order. A request_listener_shutdown/1 call for the listener may interrupt the bounded loop before Count connections are accepted.
staticserve_listener(Listener,Handler,Count,ClientInfos)serve_listener(+compound,+object_identifier,+integer,--list(compound)) - one_or_errorCount is a variable:instantiation_errorCount is not a non-negative integer:domain_error(non_negative_integer,Count)Handler does not conform to the HTTP handler protocol:domain_error(http_handler_protocol,Handler)domain_error(http_response_stream,Error)resource_error(threads)serve_listener/5
Accepts and serves Count incoming connections on the given listener using the specified shutdown and worker options. A request_listener_shutdown/1 call for the listener may interrupt the bounded loop before Count connections are accepted.
staticserve_listener(Listener,Handler,Count,ClientInfos,Options)serve_listener(+compound,+object_identifier,+integer,--list(compound),+list) - one_or_errorCount is a variable:instantiation_errorCount is not a non-negative integer:domain_error(non_negative_integer,Count)Options is a variable or a partial list:instantiation_errorOptions is neither a variable nor a list:type_error(list,Options)Option of the list Options is neither a variable nor a compound term:type_error(compound,Option)Option of the list Options is a compound term but not a valid option:domain_error(option,Option)Options contains an invalid listener-serving option:domain_error(http_socket_transport_listener_option,Option)Handler does not conform to the HTTP handler protocol:domain_error(http_handler_protocol,Handler)domain_error(http_response_stream,Error)resource_error(threads)
Option
shutdown(keep_open): Leave the listener open after serving the requested number of connections. This is the default.Option
shutdown(close): Close the listener when serving completes or aborts.Option
workers(serial): Serve accepted connections sequentially in the caller thread. This is the default.Option
workers(per_connection): Spawn one worker thread per accepted connection and wait for all workers before returning. Requires backend thread support.Option
workers(pool(Size)): Serve accepted connections in batches of up toSizeworker threads, waiting for each batch to finish before accepting the next batch. Requires backend thread support.Option
workers(pool(Size, rolling)): Serve accepted connections using at mostSizeconcurrent worker threads, accepting the next connection as soon as a worker finishes. Requires backend thread support.
serve_until_shutdown/4
Accepts and serves incoming connections on the given listener until request_shutdown/1 is called for the specified control term, then closes the listener before returning.
staticserve_until_shutdown(Listener,Handler,Control,Options)serve_until_shutdown(+compound,+object_identifier,+nonvar,+list) - one_or_errorControl is a variable:instantiation_errorControl is already registered for another open-ended listener loop:permission_error(reuse,http_socket_transport_shutdown_control,Control)Options is a variable or a partial list:instantiation_errorOptions is neither a variable nor a list:type_error(list,Options)Options contains an invalid listener-serving option:domain_error(http_socket_transport_listener_option,Option)Handler does not conform to the HTTP handler protocol:domain_error(http_handler_protocol,Handler)domain_error(http_response_stream,Error)resource_error(threads)
Control term: The control term must be non-variable and should be fresh for each open-ended serving loop.
Option
workers(serial): Serve accepted connections sequentially in the caller thread. This is the default.Option
workers(per_connection): Spawn one worker thread per accepted connection and wait for all workers when shutdown is requested. Requires backend thread support.Option
workers(pool(Size)): Serve accepted connections using at most Size concurrent worker threads, waiting for worker completion notifications before accepting additional connections. Requires backend thread support.Option
workers(pool(Size, rolling)): Alias forworkers(pool(Size)). Requires backend thread support.Shutdown behavior: Calling request_shutdown/1 wakes the serving loop, stops accepting new connections, and waits for active workers to finish before the listener is closed and the serving loop returns.
serve_until_shutdown/5
Accepts and serves incoming connections on the given listener until request_shutdown/1 is called for the specified control term, calling Ready after the shutdown control is registered and before the serving loop starts accepting connections.
staticserve_until_shutdown(Listener,Handler,Control,Options,Ready)serve_until_shutdown(*,*,*,*,0)serve_until_shutdown(+compound,+object_identifier,+nonvar,+list,+callable) - one_or_errorControl is a variable:instantiation_errorControl is already registered for another open-ended listener loop:permission_error(reuse,http_socket_transport_shutdown_control,Control)Options is a variable or a partial list:instantiation_errorOptions is neither a variable nor a list:type_error(list,Options)Options contains an invalid listener-serving option:domain_error(http_socket_transport_listener_option,Option)Handler does not conform to the HTTP handler protocol:domain_error(http_handler_protocol,Handler)domain_error(http_response_stream,Error)resource_error(threads)
Control term: The control term must be non-variable and should be fresh for each open-ended serving loop.
Ready goal: Called once after the shutdown control is registered and before the serving loop starts accepting connections.
Options: Supports the same worker options as
serve_until_shutdown/4.
request_shutdown/1
Requests shutdown of an open-ended serving loop started with serve_until_shutdown/4 or serve_until_shutdown/5 for the specified control term and wakes any blocked accept call so the loop can terminate portably.
staticrequest_shutdown(Control)request_shutdown(+nonvar) - one_or_errorControl is a variable:instantiation_errorControl is not registered for an open-ended listener loop:existence_error(http_socket_transport_shutdown_control,Control)resource_error(threads)supported_request_scheme/1
Table of supported request schemas.
staticsupported_request_scheme(Scheme)supported_request_scheme(+nonvar) - one_or_moresupported_websocket_scheme/1
Table of supported websocket schemas.
staticsupported_websocket_scheme(Scheme)supported_websocket_scheme(+nonvar) - one_or_moreProtected predicates
(none)
Private predicates
(none)
Operators
(none)