

The mentioned flags are used by these protocols to explicitly initialize a secure session after receiving a special command from a client. These flags are not used to start SSL / TLS since the HTTP protocol doesn’t support such a command.Īfter assigning an appropriate TLS mode, you need to set up the HTTP binding port. The TclTcpServerTls class represents a basic functionality for implementing different Network protocols, including IMAP and SMTP. Both these flags are intended to explicitly start a secure connection, and they are not used in the TclHttpServer component.

The UseTLS property accepts two more flags: stExplicitAllow and stExplicitRequire. If this property equals to stNone, the component works in non-secure HTTP mode. You need to use the implicit flag to enable HTTPS. There is a special property that does all the work: TclHttpServer.UseTLS. To enable the HTTPS protocol, you need to use the component in SSL / TLS mode. SendResponseAndClose(conn, E.ErrorCode, E.Message, E.Message) Ĭonn := TclHttpUserConnection(AConnection) ĭoReceiveRequest(conn, conn.RequestMethod, conn.RequestUri,

All further request processing is performed outside the component.
#EXEMPLO REST DELPHI CODE#
This code simply reads the request body from a socket, extracts headers and other request-related data, and finally, calls to the OnRequestReceived event of the TclHttpServer component. Property RequestBody: TStream read FRequestBody write SetRequestBody Īccepted requests are handled within the DoReadConnection overridden method. Property ResponseCookies: TStrings read FResponseCookies Property ResponseHeader: TclHttpResponseHeader read FResponseHeader Property ResponseVersion: TclHttpVersion read FResponseVersion write FResponseVersion Property RequestCookies: TStrings read FRequestCookies Property RequestHeader: TclHttpRequestHeader read FRequestHeader

Property RequestUri: string read FRequestUri Property RequestMethod: string read FRequestMethod Property RequestVersion: TclHttpVersion read FRequestVersion TclHttpUserConnection = class(TclUserConnectionTls)įunction AcceptRequestData(AData: TStream): Boolean TclHttpUserConnection keeps all requests and response-related data: a request URI, an HTTP method, headers, cookies, an HTTP version, and a request body, as well. Inherited DoReadConnection(AConnection, AData) Ī class that introduces a user connection (TclHttpUserConnection) should be inherited from the TclUserConnectionTls class. Procedure TclHttpServer.DoReadConnection(AConnection: TclUserConnection AData: TStream) Result := TclHttpUserConnection.Create(HttpVersion, CharSet) Procedure DoReadConnection(AConnection: TclUserConnection AData: TStream) override įunction TclHttpServer.CreateDefaultConnection: TclUserConnection įunction CreateDefaultConnection: TclUserConnection override All you need is to inherit from this basic class and override some virtual methods. There is one more class, TclTcpServerTls, that uses Microsoft Schannel and implements the SSL / TLS protocol. The previous version of the TclHttpServer component utilized the TclTcpServer class from the Clever Internet Suite library for implementing low-level Network communication.
