http server. Get one line from http request lazarus / 38-Networking and Web Programming ---------------------------------------------------------------------- Anton Shevtsov · 2017-12-20 11:45 Hi, I want simple tcp server. I need only one line of header i.e. Quote  GET /filename.ext?IP=1.2.3.4 HTTP/1.1 no body, no other lines.. only first line of http request i must use synapse. What unit, methods i can used ? p.s. simple examples are welcome )) ---------------------------------------------------------------------- rvk · 2017-12-20 11:54 Quote from: Anton Shevtsov on December 20, 2017, 12:45:35 pmno body, no other lines.. only first line of http requestDo you mean first line of the response or first line of the request ??? This is for the first line from the response: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i uses httpsend;//...var  I: Integer;  HTTP: THTTPSend;begin  HTTP := THTTPSend.Create;  try    if HTTP.HTTPMethod('HEAD', your_url) then    if HTTP.Headers.Count > 0 then        Showmessage(HTTP.Headers.Strings[0]);  finally    HTTP.Free;  end; ---------------------------------------------------------------------- Anton Shevtsov · 2017-12-20 12:01 Quote from: rvk on December 20, 2017, 12:54:52 pmQuote from: Anton Shevtsov on December 20, 2017, 12:45:35 pmno body, no other lines.. only first line of http requestDo you mean first line of the response or first line of the request ??? This is for the first line from the response: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i uses httpsend;//...var  I: Integer;  HTTP: THTTPSend;begin  HTTP := THTTPSend.Create;  try    if HTTP.HTTPMethod('HEAD', your_url) then    if HTTP.Headers.Count > 0 then        Showmessage(HTTP.Headers.Strings[0]);  finally    HTTP.Free;  end; it's client side.. i need a server side (i want see clients requests) client want download something from my server, and send request QuoteGET /filename.ext?IP=1.2.3.4 HTTP/1.1 Host: 5.6.7.8:5222 User-Agent: blablabla Accept: */* Connection: Keep-Alive i want Quoteget:=foor.bar.getheaders[0]; // GET /filename.ext?IP=1.2.3.4 HTTP/1.1and listen next request p.s. my english is terrible ))) ---------------------------------------------------------------------- rvk · 2017-12-20 12:07 Quote from: Anton Shevtsov on December 20, 2017, 01:01:41 pmit's client side.. i need a server side (i want see clients requests) client want download something from my server, and send request Ah, ok, I missed that (server) part. Synapse doesn't have a ready made component for http-server. But you can create one easily with just TTCPBlockSocket. An example can be found here and you can simply adjust it like you want: http://wiki.freepascal.org/Networking#Webserver_example For your needs it's just sufficient to get the first  s := ASocket.RecvString(timeout); in AttendConnection in the example. Although it's better to handle the complete sending of the response to the client. Otherwise the client might complain it doesn't receive anything back. Note that the ListeningSocket is the one that listens to incoming http-connections. It then passes the incoming socket to the ConnectionSocket which handles the receiving and sending of the actual data. Normally, with a complete HTTP server you would want to handle multiple incoming connections at the same time and would need to handle the ConnectionSocket in a thread (so the ListeningSocket can go on listening to new incoming connection at the same time). But for a simple example this is not necessary. ---------------------------------------------------------------------- tudi_x · 2017-12-20 13:10 you can just copy paste from : http://forum.lazarus.freepascal.org/index.php/topic,39088.0.html