Revision: 4231 Author: hans URL: http://bknr.net/trac/changeset/4231
Fix cookie parsing.
U trunk/thirdparty/chunga/doc/index.html U trunk/thirdparty/chunga/packages.lisp U trunk/thirdparty/drakma/cookies.lisp U trunk/thirdparty/drakma/read.lisp U trunk/thirdparty/drakma/util.lisp
Modified: trunk/thirdparty/chunga/doc/index.html =================================================================== --- trunk/thirdparty/chunga/doc/index.html 2009-02-10 14:46:11 UTC (rev 4230) +++ trunk/thirdparty/chunga/doc/index.html 2009-02-10 14:50:32 UTC (rev 4231) @@ -91,6 +91,7 @@ <li><a href="#assert-char"><code>assert-char</code></a> <li><a href="#skip-whitespace"><code>skip-whitespace</code></a> <li><a href="#read-char*"><code>read-char*</code></a> + <li><a href="#peek-char*"><code>peek-char*</code></a> <li><a href="#trim-whitespace"><code>trim-whitespace</code></a> <li><a href="#*current-error-message*"><code>*current-error-message*</code></a> <li><a href="#*accept-bogus-eols*"><code>*accept-bogus-eols*</code></a> @@ -640,6 +641,25 @@ <!-- End of entry for READ-CHAR* -->
+<!-- Entry for PEEK-CHAR* --> + +<p><br>[Function]<br><a class=none name='peek-char*'><b>peek-char*</b> <i>stream <tt>&optional</tt> eof-error-p eof-value</i> => <i>boolean</i></a> +<blockquote><br> + +Returns a true value if a character can be read from the binary +stream <code><i>stream</i></code>. If <code><i>eof-error-p</i></code> +has a true value, an error is signalled if no character remains to be +read. <code><i>eof-value</i></code> specifies the value to return +if <code><i>eof-error-p</i></code> is false and the end of the file +has been reached. +<p> +See <a href="#with-character-stream-semantics"><code>WITH-CHARACTER-STREAM-SEMANTICS</code></a>. + +</blockquote> + +<!-- End of entry for PEEK-CHAR* --> + + <!-- Entry for TRIM-WHITESPACE -->
<p><br>[Function]<br><a class=none name='trim-whitespace'><b>trim-whitespace</b> <i>string</i> => <i>string'</i></a>
Modified: trunk/thirdparty/chunga/packages.lisp =================================================================== --- trunk/thirdparty/chunga/packages.lisp 2009-02-10 14:46:11 UTC (rev 4230) +++ trunk/thirdparty/chunga/packages.lisp 2009-02-10 14:50:32 UTC (rev 4231) @@ -54,6 +54,7 @@ :input-chunking-unexpected-end-of-file :make-chunked-stream :read-http-headers + :peek-char* :read-char* :read-line* :read-name-value-pair
Modified: trunk/thirdparty/drakma/cookies.lisp =================================================================== --- trunk/thirdparty/drakma/cookies.lisp 2009-02-10 14:46:11 UTC (rev 4230) +++ trunk/thirdparty/drakma/cookies.lisp 2009-02-10 14:50:32 UTC (rev 4231) @@ -249,7 +249,7 @@ of three-element lists where each one contains the name of the cookie, the value of the cookie, and an attribute/value list for the optional cookie parameters." - (with-input-from-string (stream string) + (with-sequence-from-string (stream string) (loop with *current-error-message* = (format nil "While parsing cookie header ~S:" string) for first = t then nil for next = (and (skip-whitespace stream)
Modified: trunk/thirdparty/drakma/read.lisp =================================================================== --- trunk/thirdparty/drakma/read.lisp 2009-02-10 14:46:11 UTC (rev 4230) +++ trunk/thirdparty/drakma/read.lisp 2009-02-10 14:50:32 UTC (rev 4231) @@ -60,7 +60,7 @@ HTTP-REQUEST. Returns NIL if there is no such header amongst HEADERS." (when-let (content-type (header-value :content-type headers)) - (with-input-from-sequence (stream (map 'list 'char-code content-type)) + (with-sequence-from-string (stream content-type) (let* ((*current-error-message* "Corrupted Content-Type header:") (type (read-token stream)) (subtype (and (assert-char stream #/) @@ -80,8 +80,8 @@ "Reads and consumes from STREAM any number of commas and whitespace. Returns the following character or NIL in case of END-OF-FILE." - (loop while (eql (peek-char nil stream nil) #,) - do (read-char stream) (skip-whitespace stream)) + (loop while (eql (peek-char* stream nil) #,) + do (read-char* stream) (skip-whitespace stream)) (skip-whitespace stream))
(defun read-tokens-and-parameters (string &key (value-required-p t)) @@ -94,7 +94,7 @@ (the attribute/value pairs). If VALUE-REQUIRED-P is NIL, the value part (including the #\= character) of each attribute/value pair is optional." - (with-input-from-string (stream string) + (with-sequence-from-string (stream string) (loop with *current-error-message* = (format nil "While parsing ~S:" string) for first = t then nil for next = (and (skip-whitespace stream)
Modified: trunk/thirdparty/drakma/util.lisp =================================================================== --- trunk/thirdparty/drakma/util.lisp 2009-02-10 14:46:11 UTC (rev 4230) +++ trunk/thirdparty/drakma/util.lisp 2009-02-10 14:50:32 UTC (rev 4231) @@ -274,3 +274,9 @@ (or (null candidate-subtype) (string-equal subtype candidate-subtype)))))
+(defmacro with-sequence-from-string ((stream string) &body body) + "Kludge to make Chunga tokenizing functionality usable. Works like + WITH-INPUT-FROM-STRING, but creates a sequence of octets that works + with CHUNGA::PEEK-CHAR* and friends." + `(flex:with-input-from-sequence (,stream (map 'list #'char-code ,string)) + ,@body)) \ No newline at end of file