Code: Select all
(defun read-header (stream)
(with-output-to-string (header)
(loop for line = (read-line stream nil)
while (and line (string/= line (string #\Return)))
do (write-string line header))))
This is possible in SBCL in principle, but I am not sure how to make usocket produce such a stream, and I am not sure if it is a good idea. I would suggest reading the data as a stream of bytes (preferably using READ-SEQUENCE), locating header terminator as binary pattern (which would eliminate the issue above) and then decode just the header.sdp wrote:Now I just have to figure out how to read-byte from a non-binary stream.