Difference between revisions of "THttpServer"
Jump to navigation
Jump to search
| (4 intermediate revisions by one other user not shown) | |||
| Line 6: | Line 6: | ||
*'''inheritance''' THttpServer- TComponent | *'''inheritance''' THttpServer- TComponent | ||
| − | THttpServer component is implementing the server side HTTP protocol. HTTP protocol is the standard protocol for browsing the World Wide Web. | + | THttpServer component is implementing the server side HTTP protocol. HTTP protocol is the standard protocol for browsing the World Wide Web. <br>If you want to write a web application, you should use [[THttpAppSrv]] which derive from THttpServer and add a lot of nice features to ease writing HTTP application server. |
== Properties == | == Properties == | ||
| Line 12: | Line 12: | ||
{| | {| | ||
| valign="top" width="150" | [[THttpServer.Addr | Addr]] |||| Binds the server to a specific IP-address and only receives request for that IP+Port. | | valign="top" width="150" | [[THttpServer.Addr | Addr]] |||| Binds the server to a specific IP-address and only receives request for that IP+Port. | ||
| − | |- | + | |- |
| + | | valign="top" | [[THttpServer.AuthDigestMethod | AuthDigestMethod]] |||| Select the method to be used for digest authentication. | ||
| + | |- | ||
| + | | valign="top" | [[THttpServer.AuthDigestNonceLifeTimeMin | AuthDigestNonceLifeTimeMin]] |||| Life time for digest nonce. | ||
| + | |- | ||
| + | | valign="top" | [[THttpServer.AuthRealm | AuthRealm]] |||| Name space for authentication. | ||
| + | |- | ||
| + | | valign="top" | [[THttpServer.AuthTypes | AuthTypes]] |||| Allowed authentications methods. | ||
| + | |- | ||
| + | | valign="top" | [[THttpServer.DefaultDoc | DefaultDoc]] |||| Name of the default document. | ||
| + | |- | ||
| + | | valign="top" | [[THttpServer.DocDir | DocDir]] |||| Path name for the root directory where documents are stored. | ||
| + | |- | ||
| + | | valign="top" | [[THttpServer.IcsLogger | IcsLogger]] |||| Reference to the TIcsLgger component. | ||
| + | |- | ||
| + | | valign="top" | [[THttpServer.KeepAliveTimeSec | KeepAliveTimeSec]] |||| Keep alive time expressed in seconds. | ||
| + | |- | ||
| + | | valign="top" | [[THttpServer.LingerOnOff | LingerOnOff]] |||| How linger must be done. This affect the way sockets are closed. | ||
| + | |- | ||
| + | | valign="top" | [[THttpServer.LingerTimeout | LingerTimeout]] |||| How long should the socket linger when closing. | ||
| + | |- | ||
| + | | valign="top" | [[THttpServer.ListenBacklog | ListenBackog]] |||| How many connections can be queued by the OS before refusing new connections. | ||
| + | |- | ||
| + | | valign="top" | [[THttpServer.MaxClients | MaxClients]] |||| Maximum number of simultaneous client accepted. Use 0 if not limit desired. | ||
| + | |- | ||
| + | | valign="top" | [[THttpServer.MaxRequestsKeepAlive | MaxRequestsKeepAlive]] |||| MaxRequestsKeepAlive. | ||
| + | |- | ||
| + | | valign="top" | [[THttpServer.Name | Name]] |||| Component name. | ||
| + | |- | ||
| + | | valign="top" | [[THttpServer.Options | Options]] |||| Affect how the component is operating. | ||
| + | |- | ||
| + | | valign="top" | [[THttpServer.Port | Port]] |||| TCP port number the component has to listen to. | ||
| + | |- | ||
| + | | valign="top" | [[THttpServer.Tag | Tag]] |||| Tag. | ||
| + | |- | ||
| + | | valign="top" | [[THttpServer.TemplateDir | TemplateDir]] |||| Path where the component search for dynamic pages templates. | ||
| + | |} | ||
| + | '''Runtime properties'''<br> | ||
| + | {| | ||
| + | | valign="top" width="150" | [[THttpServer.ClientCount | ClientCount]] |||| Number of currently connected clients. | ||
| + | |- | ||
| + | | valign="top" | [[THttpServer.Client | Client]] |||| Array of connected clients. Index is from 0 to ClientCount - 1. | ||
| + | |- | ||
| + | | valign="top" | [[THttpServer.ClientClass | ClientClass]] |||| Reference to the class the component has to instanciate for each client. | ||
| + | |- | ||
| + | | valign="top" | [[THttpServer.WSocketServer | WSocketServer]] |||| Reference to the underlaying TWSocketServer. | ||
|} | |} | ||
| Line 24: | Line 69: | ||
== Events == | == Events == | ||
| − | {| | + | {| |
| − | | valign="top" | + | | width="90" valign="top" | [[THttpServer.OnServerStarted| OnServerStarte]] |||| Triggered when server has started listening |
| − | |- | + | |- |
| + | | valign="top" | [[THttpServer.OnServerStopped | OnServerStopped]] |||| Triggered when server has stopped listening | ||
| + | |- | ||
| + | | valign="top" | [[THttpServer.OnClientConnect | OnClientConnect]] |||| Triggered when a client has connected | ||
| + | |- | ||
| + | | valign="top" | [[THttpServer.OnClientDisconnect | OnClientDisconnect]] |||| Triggered when a client is about to disconnect. | ||
| + | |- | ||
| + | | valign="top" | [[THttpServer.OnGetDocument | OnGetDocument]] |||| Triggered when a client sent GET request. You can either do nothing and let server handle all work, or you can build a document on the fly or refuse access. | ||
| + | |- | ||
| + | | valign="top" | [[THttpServer.OnHeadDocument | OnHeadDocument]] |||| Triggered when a client sent HEAD request. You can either do nothing and let server handle all work, or you can build a document header on the fly or refuse access. | ||
| + | |- | ||
| + | | valign="top" | [[THttpServer.OnPostDocument | OnPostDocument]] |||| Triggered when a client sent POST request. You have to tell if you accept data or not. If you accept, you'll get OnPostedData event with incomming data. | ||
| + | |- | ||
| + | | valign="top" | [[THttpServer.OnPostedData | OnPostedData]] |||| Triggered when client post data and you accepted it from OnPostDocument event. When you've got all data, you have to build a reply to be sent to client. | ||
| + | |- | ||
| + | | valign="top" | [[THttpServer.OnHttpRequestDone | OnHttpRequestDone]] |||| A HTTP request has been handled on behalf of a client. | ||
| + | |- | ||
| + | | valign="top" | [[THttpServer.OnBeforeProcessRequest | OnBeforeProcessRequest]] |||| Triggered before processing any request. | ||
| + | |- | ||
| + | | valign="top" | [[THttpServer.OnFilterDirEntry | OnFilterDirEntry]] |||| Triggered to filter directory entries. | ||
| + | |- | ||
| + | | valign="top" | [[THttpServer.OnAuthGetPassword | OnAuthGetPassword]] |||| Triggered to get the password for authentication | ||
| + | |- | ||
| + | | valign="top" | [[THttpServer.OnAuthResult | OnAuthResult]] |||| TAuthResultEvent | ||
| + | |- | ||
| + | | valign="top" | [[THttpServer.OnAuthGetType | OnAuthGetType]] |||| TAuthGetTypeEvent | ||
| + | |- | ||
| + | | valign="top" | [[THttpServer.OnAuthNtlmBeforeValidate | OnAuthNtlmBeforeValidat]] |||| TAuthNtlmBeforeValidate | ||
| + | |- | ||
| + | | valign="top" | [[THttpServer.OnUnknownRequestMethod | OnUnknownRequestMethod]] |||| Triggered when an unimplemented request is received. The request headers, method, path, etc., will be populated. | ||
|} | |} | ||
Latest revision as of 19:00, 20 April 2016
Main page -> ICS components reference -> THttpServer
Contents
Overview
- unit HttpSrv.pas
- inheritance THttpServer- TComponent
THttpServer component is implementing the server side HTTP protocol. HTTP protocol is the standard protocol for browsing the World Wide Web.
If you want to write a web application, you should use THttpAppSrv which derive from THttpServer and add a lot of nice features to ease writing HTTP application server.
Properties
| Addr | Binds the server to a specific IP-address and only receives request for that IP+Port. | |
| AuthDigestMethod | Select the method to be used for digest authentication. | |
| AuthDigestNonceLifeTimeMin | Life time for digest nonce. | |
| AuthRealm | Name space for authentication. | |
| AuthTypes | Allowed authentications methods. | |
| DefaultDoc | Name of the default document. | |
| DocDir | Path name for the root directory where documents are stored. | |
| IcsLogger | Reference to the TIcsLgger component. | |
| KeepAliveTimeSec | Keep alive time expressed in seconds. | |
| LingerOnOff | How linger must be done. This affect the way sockets are closed. | |
| LingerTimeout | How long should the socket linger when closing. | |
| ListenBackog | How many connections can be queued by the OS before refusing new connections. | |
| MaxClients | Maximum number of simultaneous client accepted. Use 0 if not limit desired. | |
| MaxRequestsKeepAlive | MaxRequestsKeepAlive. | |
| Name | Component name. | |
| Options | Affect how the component is operating. | |
| Port | TCP port number the component has to listen to. | |
| Tag | Tag. | |
| TemplateDir | Path where the component search for dynamic pages templates. |
Runtime properties
| ClientCount | Number of currently connected clients. | |
| Client | Array of connected clients. Index is from 0 to ClientCount - 1. | |
| ClientClass | Reference to the class the component has to instanciate for each client. | |
| WSocketServer | Reference to the underlaying TWSocketServer. |
Methods
| Start | Starts the webserver so it lisen for incoming requests. |
Events
| OnServerStarte | Triggered when server has started listening | |
| OnServerStopped | Triggered when server has stopped listening | |
| OnClientConnect | Triggered when a client has connected | |
| OnClientDisconnect | Triggered when a client is about to disconnect. | |
| OnGetDocument | Triggered when a client sent GET request. You can either do nothing and let server handle all work, or you can build a document on the fly or refuse access. | |
| OnHeadDocument | Triggered when a client sent HEAD request. You can either do nothing and let server handle all work, or you can build a document header on the fly or refuse access. | |
| OnPostDocument | Triggered when a client sent POST request. You have to tell if you accept data or not. If you accept, you'll get OnPostedData event with incomming data. | |
| OnPostedData | Triggered when client post data and you accepted it from OnPostDocument event. When you've got all data, you have to build a reply to be sent to client. | |
| OnHttpRequestDone | A HTTP request has been handled on behalf of a client. | |
| OnBeforeProcessRequest | Triggered before processing any request. | |
| OnFilterDirEntry | Triggered to filter directory entries. | |
| OnAuthGetPassword | Triggered to get the password for authentication | |
| OnAuthResult | TAuthResultEvent | |
| OnAuthGetType | TAuthGetTypeEvent | |
| OnAuthNtlmBeforeValidat | TAuthNtlmBeforeValidate | |
| OnUnknownRequestMethod | Triggered when an unimplemented request is received. The request headers, method, path, etc., will be populated. |