[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Chicken-users] Announcement: http-server-form-posts egg
From: |
Mario Domenech Goulart |
Subject: |
Re: [Chicken-users] Announcement: http-server-form-posts egg |
Date: |
06 Nov 2006 15:29:20 -0200 |
User-agent: |
Gnus/5.09 (Gnus v5.9.0) Emacs/21.4 |
Hello Moe,
On Sun, 5 Nov 2006 23:10:07 +0200 Moe Aboulkheir <address@hidden> wrote:
> The first release of the http-server-form-posts egg is available!
>
> This egg extends the HTTP server included in the "http" egg to parse
> multipart/form-data POSTs, and exposes some functions for inspecting
> the resulting data structures. There is some example code here:
> http://chicken.wiki.br/http-server-form-posts#Examples
Thanks a lot! That's very useful.
I'm trying http-server-form-posts to upload a file and it seems that
the connection is not being closed, even if the file transfer is
finished.
What I'm doing is:
,----[ web-server.scm ]
| #!/usr/bin/csi -script
|
| (use spiffy http-server-form-posts web-scheme)
|
| (http:add-resource "/form-post"
| (lambda (req args)
| (let* ((form-fields (request->form-field-alist req))
| (file-input (alist-ref "file" form-fields string=?)))
| (with-output-to-file (form-field:file-name file-input)
| (lambda () (display (form-field:body file-input))))
| )))
|
| (start-server port: 8080 root: "." debug: #t)
`----
,----[ index.ws ]
| (html
| (body
| (form 'method "post" 'action "/form-post"
| 'enctype "multipart/form-data"
| (input 'type "file" 'name "file")
| (input 'type "submit"))))
`----
When I run web-server.scm, access http://localhost:8080/index.ws and
upload a file, spiffy shows:
[request 0 from 127.0.0.1; thread8 (of 1) started...]
[read: "POST /form-post HTTP/1.1"]
[request: method=POST, url=/form-post, protocol=HTTP/1.1]
[attributes: (("content-length" . "66947") ("content-type" .
"multipart/form-data;
boundary=---------------------------7950133381615917017783631459") ("referer" .
"http://localhost:8080/index.ws") ("connection" . "keep-alive") ("keep-alive" .
"300") ("accept-charset" . "ISO-8859-1,utf-8;q=0.7,*;q=0.7") ("accept-encoding"
. "gzip,deflate") ("accept-language" . "en-us,en;q=0.5") ("accept" .
"text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5")
("user-agent" . "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.0.7)
Gecko/20060921 Ubuntu/dapper-security Firefox/1.5.0.7") ("host" .
"localhost:8080"))]
[handling POST request...]
[thread8 (of 1) kept alive, reading next request...]
The file is transfered, but the connection doesn't seem to be closed.
Is there anything I'm missing?
Best wishes,
Mario