Hello, On Tue, 7 Nov 2006 07:30:53 +0100 "felix winkelmann" <[EMAIL PROTECTED]> wrote:
> On 11/7/06, Moe Aboulkheir <[EMAIL PROTECTED]> wrote: > > Looking at the headers alist, it seems the client sent Connection: > >Keep-alive. I am guessing that you would get the same terminal > >output ("... kept alive ...") for any kind of HTTP request where the > >client sends such a header, regardless of whether you are using > >http-server-form-posts or not. > > > > That's right. As long as the client doesn't send "Connection: close" > (HTTP/1.1) or does send "Connection: keep-alive" (HTTP/1.0), the > connection stays open, to allow persistent connections (at least, > that's my reading of the HTTP protocol). Spiffy doesn't do timeouts > yet, so it waits either on a connection breakdown or until the client > times out and closes the connection. Actually my code was buggy. I forgot to write the response header in the resource handler code. Moe: how about providing a fully functional canonical example (based on yours)? Such like: (http:add-resource "/form-post" (lambda (req args) (let* ((form-fields (request->form-field-alist req)) (file-input (alist-ref "file" form-fields string=?)) (response (string-append "You uploaded a file called " (form-field:file-name file-input) " which has a content type of " (form-field:content-type file-input) ". The contents of this file are: " (form-field:body file-input)))) ;; save the form contents to a file (assuming a directory ;; /tmp/uploads exists) (with-output-to-file (make-pathname "/tmp/uploads" (form-field:file-name file-input)) (lambda () (display (form-field:body file-input)))) ;; write the response to the client (http:write-response-header) (printf "Content-length: ~A\r\nContent-type: text/html\r\n\r\n~A" (string-length response) response)))) An example of web page for file uploading: <html> <body> <form method="post" action="/form-post" enctype="multipart/form-data" <input type="file" name="file"> <input type="submit"> </form> </body> </html> Best wishes, Mario _______________________________________________ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users