TsgcHTTPServer › Events

TsgcHTTPServer Events

Events you can handle, grouped by purpose, followed by the full alphabetical list.

Lifecycle

NameDescription
OnStartupFires after the server has started and is ready to accept connections.
OnShutdownFires after the server has stopped and no more connections are accepted.
OnTCPConnectFires after a client connects at TCP level and before the HTTP request is parsed, so the connection can be accepted or rejected.
OnConnectFires every time a client connection is established.
OnDisconnectFires every time a client connection is dropped.
OnErrorFires whenever a protocol-level error occurs while processing a client connection.
OnExceptionFires whenever an unhandled exception is raised while processing a client connection.
OnUnknownProtocolFires when the first bytes received do not look like a valid HTTP request so the connection can be accepted or rejected.
OnUnknownAuthenticationFires when authentication is enabled and the authentication method is not recognized by the server.

HTTP

NameDescription
OnBeforeCommandFires before OnCommandGet or OnCommandOther so the request can be screened, authorized, or short-circuited with a 401 response.
OnCommandGetFires when the HTTP server receives a GET, POST, or HEAD request so the application can build the response.
OnCommandOtherFires when the HTTP server receives a method other than GET, POST or HEAD (PUT, DELETE, OPTIONS, PATCH...).
OnBeforeForwardHTTPFires before an HTTP request is dispatched so it can be forwarded (reverse-proxied) to another HTTP server.
OnAfterForwardHTTPFires after an HTTP request has been forwarded so the application can inspect the result or an error returned by the upstream server.
OnHTTP2BeforeAsyncRequestFires before an HTTP/2 request is queued so the application can choose whether it runs in the pool of threads or in the connection thread.

Sessions

NameDescription
OnCreateSessionFires when the HTTP server needs to create a new session so the application can supply a custom TIdHTTPSession instance.
OnSessionStartFires when an HTTP session is started and added to the SessionList.
OnSessionEndFires when an HTTP session is closed, either explicitly or after SessionTimeout expires.
OnInvalidSessionFires when an HTTP request presents an unknown or expired session ID so the application can decide how to react.

HTTP Upload

NameDescription
OnHTTPUploadBeforeSaveFileFires before a file extracted from a multipart/form-data upload is saved to disk so the name and path can be customized.
OnHTTPUploadAfterSaveFileFires after a file extracted from a multipart/form-data upload has been saved to disk.
OnHTTPUploadReadInputFires when the multipart/form-data decoder reads a non-file input field so its value can be captured.
OnHTTPUploadBeforeCreatePostStreamFires after the request headers have been read and before the POST stream is created so the upload can be accepted or rejected.

Reliability

NameDescription
OnSendBufferFullFires when the outbound queue of a client connection has reached its configured limit, before the overflow policy is applied.

Security

NameDescription
OnAuthenticationFires when authentication is enabled so the application can check user and password and accept or reject the connection.
OnSSLGetHandlerFires before the SSL handler is created so a custom server-side handler instance can be supplied.
OnSSLAfterCreateHandlerFires after the SSL handler has been created so its properties can be customized.
OnSSLALPNSelectFires during an ALPN-enabled handshake so the application can pick which protocol to negotiate.
OnSSLVerifyPeerFires when VerifyCertificate is enabled and the client presents a certificate to be accepted or rejected.

All Events (alphabetical)

NameDescription
OnAfterForwardHTTPFires after an HTTP request has been forwarded so the application can inspect the result or an error returned by the upstream server.
OnAuthenticationFires when authentication is enabled so the application can check user and password and accept or reject the connection.
OnBeforeCommandFires before OnCommandGet or OnCommandOther so the request can be screened, authorized, or short-circuited with a 401 response.
OnBeforeForwardHTTPFires before an HTTP request is dispatched so it can be forwarded (reverse-proxied) to another HTTP server.
OnCommandGetFires when the HTTP server receives a GET, POST, or HEAD request so the application can build the response.
OnCommandOtherFires when the HTTP server receives a method other than GET, POST or HEAD (PUT, DELETE, OPTIONS, PATCH...).
OnConnectFires every time a client connection is established.
OnCreateSessionFires when the HTTP server needs to create a new session so the application can supply a custom TIdHTTPSession instance.
OnDisconnectFires every time a client connection is dropped.
OnErrorFires whenever a protocol-level error occurs while processing a client connection.
OnExceptionFires whenever an unhandled exception is raised while processing a client connection.
OnHTTP2BeforeAsyncRequestFires before an HTTP/2 request is queued so the application can choose whether it runs in the pool of threads or in the connection thread.
OnHTTPUploadAfterSaveFileFires after a file extracted from a multipart/form-data upload has been saved to disk.
OnHTTPUploadBeforeCreatePostStreamFires after the request headers have been read and before the POST stream is created so the upload can be accepted or rejected.
OnHTTPUploadBeforeSaveFileFires before a file extracted from a multipart/form-data upload is saved to disk so the name and path can be customized.
OnHTTPUploadReadInputFires when the multipart/form-data decoder reads a non-file input field so its value can be captured.
OnInvalidSessionFires when an HTTP request presents an unknown or expired session ID so the application can decide how to react.
OnSendBufferFullFires when the outbound queue of a client connection has reached its configured limit, before the overflow policy is applied.
OnSessionEndFires when an HTTP session is closed, either explicitly or after SessionTimeout expires.
OnSessionStartFires when an HTTP session is started and added to the SessionList.
OnShutdownFires after the server has stopped and no more connections are accepted.
OnSSLAfterCreateHandlerFires after the SSL handler has been created so its properties can be customized.
OnSSLALPNSelectFires during an ALPN-enabled handshake so the application can pick which protocol to negotiate.
OnSSLGetHandlerFires before the SSL handler is created so a custom server-side handler instance can be supplied.
OnSSLVerifyPeerFires when VerifyCertificate is enabled and the client presents a certificate to be accepted or rejected.
OnStartupFires after the server has started and is ready to accept connections.
OnTCPConnectFires after a client connects at TCP level and before the HTTP request is parsed, so the connection can be accepted or rejected.
OnUnknownAuthenticationFires when authentication is enabled and the authentication method is not recognized by the server.
OnUnknownProtocolFires when the first bytes received do not look like a valid HTTP request so the connection can be accepted or rejected.