fukamachi / ningle

Super micro framework for Common Lisp
http://8arrow.org/ningle/
273 stars 25 forks source link

POST body-parameters are being lost such as the filenames when uploading files #21

Closed resttime closed 7 years ago

resttime commented 7 years ago

3e60411f62668ca79c681b9cc6549f78826c6a88

I think this commit is causing lost to access of relevant body parameters in the route definition's lexical environment. For example if we want to know the file name of a file a user uploads via a POST Form, the hash-tables that used to contain the name are no longer available. I tested with these routes before/after reverting the commit.

(setf (ningle:route *app* "/")
      (cl-markup:html5
       (:form :id "post-form" :action "/" :method "POST" :enctype "multipart/form-data"
              (:input :type "file" :name "myfile")
              (:input :type "text" :name "sup")
              (:input :type "submit" :value "Post"))
       ))

(setf (ningle:route *app* "/" :method :POST)
      #'(lambda (params)
          (let ((bp (getf (lack.request:request-env *request*) :body-parameters)))
            (format nil "<b>Parameters:</b> ~a~%<b>Request Env:</b> ~a~%" params bp))))
resttime commented 7 years ago

Ah, I suppose this is a nonissue if we put our webserver behind a reverse proxy that can deal with uploads and then passes the relevant information.

https://www.nginx.com/resources/wiki/modules/upload/