retrieve the header only from a http web server
you can get the exe "webhead.exe" for a short time from today at
Code:
'compile with pbcc 4.03 or 4.04 'webhead.bas #COMPILE EXE DEFLNG a-z FUNCTION PBMAIN() serverlocation$=LCASE$(TRIM$(COMMAND$)) IF LEN(serverlocation$)>1 THEN IF RIGHT$(serverlocation$,1)="/" THEN serverlocation$=LEFT$(serverlocation$,(LEN(serverlocation$)-1)) END IF serverport = 80 'Port (should be 80) fileURL$ = "http://"+serverlocation$ 'Filename to grab TCP OPEN PORT serverport AT serverlocation$ AS #1 TIMEOUT 15000 'Open server PRINT PRINT "requesting http header from" PRINT FILEURL$ IF ISFALSE(CONSOUT) THEN STDOUT "requesting http header from" IF ISFALSE(CONSOUT) THEN STDOUT fileurl$ TCP PRINT #1, "HEAD " + FILEURL$+ " HTTP/1.0" TCP PRINT #1, "Host: " + serverlocation$ TCP PRINT #1, "" buffer$=SPACE$(4096) 'Download file received$="" IF ERR THEN PRINT "server not found" IF ISFALSE(CONSOUT) THEN STDOUT "server not found" EXIT FUNCTION END IF DO TCP RECV #1, 4096, buffer$ 'Download 4k block IF buffer$ = "" THEN EXIT DO 'Done? received$ = received$ & buffer$ 'Append to total file buffer LOOP TCP CLOSE #1 'Disconnect from server PRINT "server found" IF ISFALSE(CONSOUT) THEN STDOUT "server found" received$=TRIM$(received$) STDOUT $CRLF+received$ IF ISFALSE(CONSOUT) THEN PRINT:PRINT "see redirected output for http header information" END FUNCTION
Comment