(defun make-stream-for-request (req content-length)
"Construct a Lisp input flexi-stream from the binary stream provided
by the HTTPServletRequest. Set the bound of the stream to the value of
the Content-Length header, if any."
(let* ((java-stream (#"getInputStream" req))
(lisp-stream (jss:new :|lisp.Stream|
(jss:get-java-field :|lisp.Symbol| "SYSTEM_STREAM") ; structureClass
java-stream
'(unsigned-byte 8)))) ; elementType
(make-flexi-stream lisp-stream
:external-format +latin-1+
:bound content-length)))