[bknr-cvs] hans changed trunk/thirdparty/hunchentoot/request.lisp

BKNR Commits bknr at bknr.net
Fri Aug 21 12:40:28 UTC 2009


Revision: 4447
Author: hans
URL: http://bknr.net/trac/changeset/4447

Stephen P. Compall's patch to fix problems with multipart/form-data request
bodies:

As of r4438 (Peter's patch), I believe this wipes out post-parameters of
multipart/form-data POST requests and causes the relevant requests to
time out.

Specifically, on a multipart/form-data request, the first call to
`post-parameters` yields a sensible result, whereas future calls yield
NIL after timing out.

The solution proper is in the first hunk of the patch below, which
removes the ability to FORCE maybe-read-post-parameters to reread a
multipart/form-data request, because it can't do that, having emptied
the stream of the necessary data.

The second hunk, which incidentally fixes the problem as well (only by
avoiding the confusing behavior of maybe-read-post-parameters in the
common case of POSTing a non-empty set of parameters, rather than
solving it), is a specific followup to r4438, which in combination with
the first hunk merely prevents post-parameters from recalculating the
alist from the raw data on every call.

Were the first hunk to be changed to warn in the specific case it
avoids, the second hunk would also serve to eliminate spurious warnings
about being unable to reread multipart posts.

U   trunk/thirdparty/hunchentoot/request.lisp

Modified: trunk/thirdparty/hunchentoot/request.lisp
===================================================================
--- trunk/thirdparty/hunchentoot/request.lisp	2009-08-20 12:42:30 UTC (rev 4446)
+++ trunk/thirdparty/hunchentoot/request.lisp	2009-08-21 12:40:26 UTC (rev 4447)
@@ -289,7 +289,9 @@
   (when (and (header-in :content-type request)
              (member (request-method request) *methods-for-post-parameters* :test #'eq)
              (or force
-                 (not (slot-value request 'raw-post-data))))
+                 (not (slot-value request 'raw-post-data)))
+	     ;; can't reparse multipart posts, even when FORCEd
+	     (not (eq t (slot-value request 'raw-post-data))))
     (unless (or (header-in :content-length request)
                 (input-chunking-p))
       (log-message :warning "Can't read request body because there's ~
@@ -357,7 +359,8 @@
   ;; in. (For instance, if SEND-HEADERS has been called, filling in
   ;; RAW-POST-DATA, and then subsequent code calls POST-PARAMETERS,
   ;; without the :FORCE flag POST-PARAMETERS would return NIL.)
-  (maybe-read-post-parameters :request request :force t))
+  (maybe-read-post-parameters
+   :request request :force (not (slot-value request 'post-parameters))))
 
 (defun post-parameters* (&optional (request *request*))
   "Returns an alist of the POST parameters associated with the REQUEST





More information about the Bknr-cvs mailing list