Identify the web server of any URL  

Send By: BackSpace
Web : N.A.
Email: webmaster@esimtz.colombus.cu
Date: 27/02/00

Tip accessed 543 times

 


If we send a " GET " to a web server at port 80, it will return us something similar to this:

 HTTP/1.0 200 OK
 Date: Fri, 18.Feb 2000 09:42:29 GMT
 Server: Apache/1.3.6 (Unix)   <===  Esta es la parte interesante
 Connection: close
 Transfer-Encoding: chunked
 Content-Type: text/html
 ...
 ...
 Codigo HTML
 ...



The request must be:
GET / HTTP/1.0{CR/LF}{CR/LF}{CR/LF}

The example:

  • Add one TClientSocket, one TMemo, one TEdit and one TButton.
  • In the Connect event of the TClientSocket, put this code:


     procedure TForm1.ClientSocket1Connect(Sender: TObject; Socket: TCustomWinSocket);
     begin
      Caption := 'Conectado'; {Connected}
      ClientSocket1.Socket.SendText('GET / HTTP/1.0'+#13+#10+#13+#10+#13+#10);
     end;
    



  • in the Read even of the TClientSocket:


     procedure TForm1.ClientSocket1Read(Sender: TObject;
       Socket: TCustomWinSocket);
     begin
       Memo1.Lines.Add(ClientSocket1.Socket.ReceiveText);
     end;
    



  • And in the OnCLick of the TButton:


     procedure TForm1.Button1Click(Sender: TObject);
     begin
      ClientSocket1.Host := Edit1.Text;
      ClientSocket1.Port := 80;
      ClientSocket1.Open;
     end;
    



    Run the program, and write in the TEdit the server address, ex: 'www.q3.nu' , 'www.altavista.com', etc.

    For 'www.q3.nu' you will get something similar to this:


     HTTP/1.1 200 OK
     Date: Thu, 24 Feb 2000 21:00:41 GMT
     Server: Apache 1.3.6 Skyport Version Server built   May 4 1999 20:10:57