[DUG] Emulate a very basic web server using TCPServer

Jolyon Smith jsmith at deltics.co.nz
Mon Mar 21 16:56:59 NZDT 2011


I suggest you look at the properties of the TIdHTTPRequestInfo object you
get, corresponding to a browser request.

 

All the information you need can be found there I suspect.  J

 

 

From: delphi-bounces at delphi.org.nz [mailto:delphi-bounces at delphi.org.nz] On
Behalf Of Ross Levis
Sent: Monday, 21 March 2011 16:47
To: 'NZ Borland Developers Group - Delphi List'
Subject: [DUG] Emulate a very basic web server using TCPServer

 

I've got a TCP Client/Server app using Indy10 which communicates using my
own protocol, but I have a situation where I want to send information to a
browser using the same TCP Server using the same port, rather than
implementing a separate Indy HTTP server.

 

All I need is to retrieve the URL path entered into the browser, and return
some content based on that.

 

I can currently do everything except determine the URL path.  My IE browser
is sending information like this.

 

User-Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0;
GTB6.6; .NET CLR 1.1.4322; InfoPath.2; .NET CLR 2.0.50727; FDM; .NET CLR
3.0.04506.648; .NET CLR 3.5.21022; .NET CLR 3.0.4506.2152; .NET CLR
3.5.30729; Open Codecs 0.85.17766)

Accept-Encoding: gzip, deflate

Host: localhost:2323

Connection: Keep-Alive

 

What I entered into the browser was http://localhost:2323/test  and I need
the "/test" to know what to send back.

 

I assume I need to send something back to the browser to ask for the path.
I could likely spend hours reading the HTTP 1.1 specifications but I'm
hoping someone may know.

 

Cheers,

Ross.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://listserver.123.net.nz/pipermail/delphi/attachments/20110321/634d71b0/attachment.html 


More information about the Delphi mailing list