TCPServer sends html to browser

I am working on a project in which I have to implement a simple web server to display a welcome page. So I put TTCPServer in my form, and I can successfully send plain text to a browser that interacts with the server. But how can I send HTML?

I tried this but did not work.

ClientSocket.Sendln('HTTP/1.0 200 OK');
ClientSocket.Sendln('MIME-version: 1.0');
ClientSocket.Sendln('Content-type: text/html');
ClientSocket.Sendln('Content-Length:'+IntToStr(Length(webpage)+10));
ClientSocket.Sendln(AnsiString(Format(webpage, [va, ma, mi, timexx])));

Any ideas? In any case, I do not want to use another component.

+5
source share
1 answer

You will need an additional CRLF after the last header so that the browser can determine the final headers and the start of the body.

+7
source

All Articles