Bugs item #546193, was opened at 2002-04-19 18:30
Message generated for change (Comment added) made by skeptomai
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=447472&aid=546193&group_id=46815
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: None
Group: None
>Status: Closed
Resolution: Fixed
Priority: 5
Private: No
Submitted By: John Wiseman (jjwiseman)
>Assigned to: Christopher Brown (skeptomai)
Summary: sockets example newline error
Initial Comment:
The sockets http example makes a common mistake by
using read-line for reading lines and ~% to output
newlines.
HTTP lines are terminated by CR LF. ~% may output LF
on a unix system, CR on a Mac, and CR LF in Windows.
Similarly, read-line will consider a line to be
terminated by diffrent characters or sequences of
characters on different systems.
----------------------------------------------------------------------
>Comment By: Christopher Brown (skeptomai)
Date: 2007-01-28 10:57
Message:
Logged In: YES
user_id=1618180
Originator: NO
Fixed in sockets.html 1.10
----------------------------------------------------------------------
Comment By: John Wiseman (jjwiseman)
Date: 2002-06-07 08:31
Message:
Logged In: YES
user_id=374464
The code still uses read-line to read HTTP requests, and
uses #\Newline when sending HTTP requests.
I think the most portable replacement for #\Return and
#\Newline (which is actually a carriage return on Mac OS
before 10, e.g.) is to use (code-char 13) and (code-char 10).
I've attached code I've used to read telnet-style
CRLF-terminated lines in several lisps, you might want to
use something like this.
(defun read-telnet-line (stream eof-error-p eof)
"Read a CRLF-terminated line"
(if (stream-eof-p stream)
eof
(let ((line (make-array 10 :element-type 'character
:adjustable t :fill-pointer 0))
(char nil))
(do () ((or (eq eof (setq char (read-char stream
eof-error-p eof)))
(and (eql char *cr*) (eql (peek-char nil
stream) *lf*)))
(when (not (eq char eof)) (read-char stream))
(values line (null char)))
(vector-push-extend char line)))))
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=447472&aid=546193&group_id=46815
|