[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Chicken-users] url-encoded arguments et similia
From: |
felix winkelmann |
Subject: |
Re: [Chicken-users] url-encoded arguments et similia |
Date: |
Thu, 26 May 2005 08:56:26 +0200 |
On 5/26/05, Michele Simionato <address@hidden> wrote:
> After yesterday praise, let's come back to the usual posts of problems
> & issues ;)
> It seems I cannot get argument, current-urlencoded-arguments, post-var
> and get-var working. Here is an example of the issue:
>
> (define-http-resource (/get-a-b a b)
> `(div
> (form (@ (method "get"))
> (input (@ (type "text") (name "a"))) (br)
> (input (@ (type "text") (name "b"))) (br)
> (input (@ (type "submit") (name "ok"))))
> ,(format "a = ~s b = ~s args = ~a" a b
> (current-urlencoded-arguments))))
>
> (current-urlencoded-arguments) gives the empty string all the time, no
> matter what is in the query string. For instance if I point my browser to
>
> http://localhost:4242/get-a-b?a=1&b=2&ok
>
> I get
>
> a = "1" b = "2" args = ()
>
> What am I missing?
>
That parameter is only bound in the "fallback-handler", that is, for special
requests like .ssp pages.
Here's a patch for spiffy.scm:
cd /home/fwinkel/tmp/
diff -c /home/fwinkel/tmp/spiffy.scm\~ /home/fwinkel/tmp/spiffy.scm
--- /home/fwinkel/tmp/spiffy.scm~ 2005-03-02 23:07:13.000000000 +0100
+++ /home/fwinkel/tmp/spiffy.scm 2005-05-26 08:48:40.131738408 +0200
@@ -48,14 +48,15 @@
`(http:add-resource
,url
(lambda (,req ,args)
- (call/cc
- (lambda (,ret)
- (let ([respond (http-resource:responder ,req ,ret)])
- (handle-exceptions exn
- (parameterize ([http:error-response-handler
(http-resource:error-handler exn)])
- (http:write-error-response 500 "Internal Server Error") )
- (respond
- (let ,(map (lambda (arg)
- `(,(string->symbol (car arg)) (alist-ref ,(car
arg) ,args
string-ci=? ,(cdr arg))) )
- rargs)
- ,@body) ) ) ) ) ) ) ) ) )
+ (parameterize ((current-urlencoded-arguments ,args))
+ (call/cc
+ (lambda (,ret)
+ (let ([respond (http-resource:responder ,req ,ret)])
+ (handle-exceptions exn
+ (parameterize ([http:error-response-handler
(http-resource:error-handler exn)])
+ (http:write-error-response 500 "Internal Server Error") )
+ (respond
+ (let ,(map (lambda (arg)
+ `(,(string->symbol (car arg)) (alist-ref ,(car
arg) ,args
string-ci=? ,(cdr arg))) )
+ rargs)
+ ,@body) ) ) ) ) ) ) ) ) ) )
cheers,
felix