WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

WinInet
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Return Info on Web Server

Keywords: 	 web server info headers

Question:

Is it possible to use the Inet Extender to return information about a given web server ?

Perhaps, even just the server name and software (Apache).

Answer:

Try:
AddExtender("WWINT34I.DLL")

tophandle=iBegin(0,"","")
connecthandle=iHostConnect(tophandle, "www.worldwideschool.org",@HTTP,"","")
datahandle=iHttpInit(connecthandle, "GET", "/", "",0)
rslt=iHttpOpen(datahandle, "", 0, 0)
headers=iHttpHeaders(datahandle)
iClose(datahandle)
iClose(connecthandle)
iClose(tophandle)

AskItemList("Headers were",headers,@tab,@unsorted,@single)

;parse for server.
webserver=itemextract(2,headers,@tab)
message("Server type:",webserver)

exit
or a little bit cleaner:


AddExtender("WWINT34i.DLL")
tophandle=iBegin(0,"","")
host="www.worldwideschool.org"
;host="www.winbatch.com"
connecthandle=iHostConnect(tophandle, host, @HTTP,"","")
datahandle=iHttpInit(connecthandle, "GET", "/", "",0)
rslt=iHttpOpen(datahandle, "", 0, 0)
headers=iHttpHeaders(datahandle)
iClose(datahandle)
iClose(connecthandle)
iClose(tophandle)

ptr=StrIndexNC(headers,"Server: ",0,@FWDSCAN)
If ptr != -1
   ptr2=StrIndex(headers,@TAB,ptr,@FWDSCAN)
   If ptr2==0 Then ptr2=StrLen(headers)
   ptr=ptr+StrLen("Server: ")
   ServerType=StrTrim(StrSub(headers,ptr,ptr2-ptr))
Else
   ServerType="Unknown"
EndIf

Message("Server Type",ServerType)
Exit





Article ID:   W14560
Filename:   Return Info on Web Server.txt
File Created: 2017:07:28:12:58:48
Last Updated: 2003:05:28:09:18:21