Anyway, if there was such a query, the following works, but ....
Code: Select all
1000 CLS
1010 OPEN_IN #3,'tcp_www.dilwyn.me.uk:80'
1020 PRINT #3, 'GET /index.html HTTP/1.1' & CHR$(13) & CHR$(10);
1030 PRINT #3, 'HOST:dilwyn.me.uk' & CHR$(13) & CHR$(10) & CHR$(13) & CHR$(10);
1040 REPeat loop
1050 IF EOF(#3) THEN EXIT loop: END IF
1060 INPUT #3, html$
1070 FOR x = 1 TO LEN(html$)
1080 IF html$(x) = CHR$(13) THEN EXIT x: END IF
1090 PRINT html$(x);
1100 END FOR x
1110 PRINT
1120 END REPeat loop
1130 CLOSE #3
Code: Select all
HTTP/1.1 301 Moved Permanently
Date: Mon, 27 Feb 2017 20:22:17 GMT
Server: Apache/2.2.22 (Debian)
Location: http://www.dilwyn.me.uk/index.html
Vary: Accept-Encoding
Content-Length: 320
Content-Type: text/html; charset=iso-8859-1
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>301 Moved Permanently</title>
</head><body>
<h1>Moved Permanently</h1>
<p>The document has moved <a href="http://www.dilwyn.me.uk/index.html">here</a>.</p>
<hr>
<address>Apache/2.2.22 (Debian) Server at dilwyn.me.uk Port 80</address>
</body></html>
1. It never hits EOF, so just sits there, looping the loop and printing nothing. CTRL+SPACE required. I suppose I could use the "Content-Length:" header to get the size of the data and work from that.
2. OPEN_IN? WTF? I tried everything OPEN, OPEN_NEW, OPEN_OVER and either got EOF, or errors. I accidentally typed OPEN_IN and it bloody worked. But I'm PRINTing to an input channel. Confused? Yup, me too!
3. There needs to be Windows style line ends. CHR$(13), CHR$(10);
4. You need a blank line after sending the HOST command. Because most/all web sites are on shared servers.
5. I suspect the output won't be helpful. The error return from HTTP, in the first string returned, is always "HTTP/1.1 301 Moved Permanently" - Looks like there's more to the underlying use of HTTP than meets the eye!
6. There's always a blank line between the last header record and the actual content of the page.
7. The web site appears to have moved, but the location given for the new destination is, exactly the same as the one I just opened. I feel the need to RTFM (or at least the RFC) coming on soon!
HTH
Cheers,
Norm.