<div>John, don't forget to publish your results when you have clack working with ABCL</div><div>š</div><div>19.11.2015, 01:24, "John Pallister" <john@synchromesh.com>:</div><blockquote type="cite"><div>Hello list,<div>š</div><div>I'm trying to get Clack (<a href="http://clacklisp.org/">http://clacklisp.org/</a>) running on Google App Engine which means doing a Java Servlets back-end. Clack expects a :RAW-BODY request header that is an input stream, and the HTTPServletRequest object I receive from the Jetty web server inherits a getReader() method (for a character stream) and a getInputStream() method (for a binary stream).</div><div>š</div><div>Looking at the "reference implementation" (i.e. Hunchentoot), it creates a FLEXI-STREAM so that any HTTP "Content-Length" header can be used to set the bound on the stream. So based on that, and an IRC chat with Mark E., and some scratch code, I've come up with this to create a FLEXI-STREAM from the HTTPServletRequest:</div><div>š</div><div><div>(defconstant +latin-1+</div><div>š (make-external-format :latin1 :eol-style :lf)</div><div>š "A FLEXI-STREAMS external format used for `faithful' input and</div><div>output of binary data (via hunchentoot/specials.lisp).")</div><div>š</div></div><div><div><div>(defun make-stream-for-request (req content-length)</div><div>š "Construct a Lisp input flexi-stream from the binary stream provided</div><div>by the HTTPServletRequest. Set the bound of the stream to the value of</div><div>the Content-Length header, if any."</div><div>š (let* ((java-stream (#"getInputStream" req))</div><div><span style="white-space:pre;"> </span> (lisp-stream (jss:new :|lisp.Stream|</div><div><span style="white-space:pre;"> </span> š š š (jss:get-java-field :|lisp.Symbol| "SYSTEM_STREAM") ; structureClass</div><div><span style="white-space:pre;"> </span> š š š java-stream</div><div><span style="white-space:pre;"> </span> š š š '(unsigned-byte 8)))) ; elementType</div><div>š š (make-flexi-stream lisp-stream</div><div><span style="white-space:pre;"> </span> š š š :external-format +latin-1+</div><div><span style="white-space:pre;"> </span> š š š :bound content-length)))</div></div></div><div>š</div><div><div><div>We agreed that there's not much documentation around this, hence this email.</div><div>š</div><div>Cheers,</div><div>š</div><div>John :^P</div><div>-- <br />John Pallister<br /><a href="mailto:john@johnp.net" target="_blank">john@johnp.net</a><br /><a href="mailto:john@synchromesh.com" target="_blank">john@synchromesh.com</a></div></div></div></div></blockquote>