[drakma-devel] Sending content without loading it all in memory?

Zach Beane xach at xach.com
Mon Oct 20 15:33:01 UTC 2008


On Wed, Sep 10, 2008 at 11:07:49AM -0400, Zach Beane wrote:
> On Wed, Sep 10, 2008 at 05:03:33PM +0200, Edi Weitz wrote:
> > On Wed, 10 Sep 2008 09:20:30 -0400, Zach Beane <xach at xach.com> wrote:
> > 
> > > Is there any way to send a non-chunked request without having the
> > > entire content in memory at once?
> > 
> > You can set the content length header yourself.  In that case Drakma
> > shouldn't use chunked encoding IIRC.
> > 
> >   http://weitz.de/drakma/#content-length

Attached is a small patch that updates Drakma so it doesn't reject a
content-length if content is :continuation. It has allowed me to
upload big files without loading them into memory first.

Zach
-------------- next part --------------
diff --git a/doc/index.html b/doc/index.html
index 1474aae..3e3057e 100755
--- a/doc/index.html
+++ b/doc/index.html
@@ -871,7 +871,9 @@ use <a href="http://weitz.de/chunga/">chunked encoding</a> to send the
 content body.  Note that this will not work with some older web
 servers.
 <p>
-<a class=none name="content-length2">A non-<code>NIL</code> <code><i>content-length</i></code> argument</a>
+When <code><i>content</i></code> is
+not <code>:CONTINUATION</code>, <a class=none name="content-length2">a
+non-<code>NIL</code> <code><i>content-length</i></code> argument</a>
 means that Drakma <em>must</em> build the request body in RAM and
 compute the content length even if it would have otherwise used
 chunked encoding - for example in the case of file uploads.  A special
diff --git a/request.lisp b/request.lisp
index f56a113..fac9cb1 100755
--- a/request.lisp
+++ b/request.lisp
@@ -386,8 +386,6 @@ LispWorks 5.0 or higher."
     (error "Don't know how to handle scheme ~S." (uri-scheme uri)))
   (when (and close keep-alive)
     (error "CLOSE and KEEP-ALIVE must not be both true."))
-  (when (and (eq content :continuation) content-length)
-    (error "CONTENT-LENGTH must be NIL if CONTENT is :CONTINUATION."))
   (when (and form-data (not (eq method :post)))
     (error "FORM-DATA makes only sense with POST requests."))
   ;; convert PROXY argument to canonical form


More information about the Drakma-devel mailing list