The Clever Internet Suite library provides a special TclSimpleHttpServer component, which works in the single-threaded blocking mode.
The usage of this component is really simple:
simpleServer := TclSimpleHttpServer.Create(nil);
port := simpleServer.Listen(80);
reqBody := simpleServer.AcceptRequest();
reqVersion := simpleServer.RequestVersion;
reqMethod := simpleServer.RequestMethod;
reqUrl := simpleServer.RequestUri;
reqContentType := simpleServer.RequestHeader.ContentType;
reqContentLength := simpleServer.RequestHeader.ContentLength;
simpleServer.ResponseVersion := hvHttp1_1;
simpleServer.ResponseHeader.ContentType := 'text/html';
simpleServer.KeepConnection := True;
simpleServer.SendResponse(200, 'OK', '<html><body>body content....</body></html>');
reqBody := simpleServer.AcceptRequest();
....etc.
Article ID: 79, Created: June 28, 2016 at 6:44 PM, Modified: November 25, 2019 at 6:11 PM