Thomas A. Russ <tar@sevak.isi.edu> wrote:
+---------------
| Here is a simple example that uses the slightly easier HTTP/1.0
| protocol to get the page:
...
| ;; It is important here to make sure you get the right number of CR/LF
| ;; pairs. There needs to be a blank line.
| ;; FINISH-OUTPUT is also critical to make sure the request is sent
| ;; before listening for a reply, otherwise you can hang.
| (defun send-get-request (stream path)
| (format stream "GET ~A HTTP/1.0" path)
| (write-crlf stream)
| (write-crlf stream)
| (finish-output stream))
+---------------
You really, *really* want to use an HTTP/1.1 "Host:" header
even when doing HTTP/1.0 requests, since named-based virtual
hosting is ubiquitous these days. E.g.:
(defconstant +crlf+ (coerce (list #\Return #\Linefeed) 'string))
(defun send-get-request (stream host path)
(format stream "GET ~A HTTP/1.0~AHost: ~A~A~A"
path +crlf+ host +crlf+ +crlf+)
(finish-output stream))
[And, yes, the FINISH-OUTPUT (or FORCE-OUTPUT) *is* critical...]
Since your TEST function already had a HOST input argument,
this is a simple addition.
-Rob
-----
Rob Warnock <rpw3@rpw3.org>
627 26th Avenue <URL:http://rpw3.org/>
San Mateo, CA 94403 (650)572-2607