|
EternalLines.com:
Components:
HTTP Server:
Documentation
How to install the component:
How the component works: The HTTP Server component works by 'listening' on a 'port' for incoming connections. The default port for HTTP (Web) requests is 80. When a new connection is made to the server, the server creates a new thread to service the connection (the client). Once the connection is established, the server will wait for the HTTP request from the client and decode it into a Request object. At this stage an event handler is called (OnGetResponse) where the user can inspect the properties of the Request object and set the response using the properties of a Response object. How to use the component:
The response object - ThttpResponse: Important properties:
StatusCode: Integer
This property must be set to the value of an HTTP response code.
A full list is defined in cHTTP unit.
The most important ones are:
http_OK = 200;
http_PartialContent = 206;
http_MovedPermanently = 301;
http_NotModified = 304;
http_TemporaryRedirect = 307;
http_BadRequest = 400;
http_Unauthorized = 401;
http_Forbidden = 403;
http_NotFound = 404;
http_MethodNotFound = 405;
http_InternalServerError = 500;
http_NotImplemented = 501;
http_ServiceUnavailable = 503;
ContentType: String
This property must be set to a valid MIME content type,
for example text/html or text/ascii.
ContentAsString: String
ContentAsStream: AReaderEx
Either of these properties must be set to the response content
(eg the HTML file).
The cReaders unit contains Reader classes that can be passed
to ContentAsStream, for example:
ContentAsStream := TFileReader.Create('c:\inetpub\index.html');
The request object - ThttpRequest:Important properties:
Method: String
Usually GET, PUT, POST or HEAD.
URI: String
The path.
Host: String
Value of the Host field.
Referer: String
The referer field. Page from which this link was refered.
|