Re: [Gauche-devel] http post troubles
R7RS Scheme scripting engine
Status: Beta
Brought to you by:
shirok
From: Shiro K. <sh...@la...> - 2010-02-27 17:14:43
|
How about this? --shiro =================================================================== --- cgi.scm (revision 7066) +++ cgi.scm (working copy) @@ -319,12 +319,18 @@ (,*rfc822-atext-chars* . ,rfc822-dot-atom))) '())) + (define (get-option optname optregex opts) + (cond [(member optname opts) => cadr] + [(any (lambda (token) + (and (string? token) (rxmatch optregex token))) + opts) => (cut rxmatch-after <>)] + [else #f])) + (define (handle-part part-info inp) - (let* ((cd (part-ref part-info "content-disposition")) - (opts (parse-content-disposition cd)) - (name (cond ((member "name=" opts) => cadr) (else #f))) - (filename (cond ((member "filename=" opts) => cadr) (else #f))) - ) + (let* ([cd (part-ref part-info "content-disposition")] + [opts (parse-content-disposition cd)] + [name (get-option "name=" #/^name=/ opts)] + [filename (get-option "filename=" #/^filename=/ opts)]) (cond ((not name) ;; if no name is given, just ignore this part. (ignore-handler name filename part-info inp) =================================================================== From: Jens Thiele <ka...@be...> Subject: Re: [Gauche-devel] http post troubles Date: Wed, 17 Feb 2010 21:50:00 +0100 > sorry, the last part is slightly wrong: > > Jens Thiele <ka...@be...> writes: > >> and I guess the problem is there: >> >>> (rfc822-field->tokens "Content-Disposition: form-data; name=\"a\"" `((#[\"] . ,content-disposition-string) (,*rfc822-atext-chars* . ,rfc822-dot-atom))) >> => ("Content-Disposition" #\: "form-data" #\; "name=" "a") >>> (rfc822-field->tokens "Content-Disposition: form-data; name=a" `((#[\"] . ,content-disposition-string) (,*rfc822-atext-chars* . ,rfc822-dot-atom))) >> => ("Content-Disposition" #\: "form-data" #\; "name=a") > > > This should be: > > (rfc822-field->tokens "form-data; name=\"a\"" `((#[\"] . ,content-disposition-string) (,*rfc822-atext-chars* . ,rfc822-dot-atom))) > => ("form-data" #\; "name=" "a") > > vs. > > (rfc822-field->tokens "form-data; name=a" `((#[\"] . ,content-disposition-string) (,*rfc822-atext-chars* . ,rfc822-dot-atom))) > => ("form-data" #\; "name=a") > > As this #?= "trace" shows: > > #?="/home/jens/down/scheme/gauche/svn/trunk/lib/www/cgi.scm":325:(part-ref part-info "content-disposition") > #?- "form-data; name=a" > #?="/home/jens/down/scheme/gauche/svn/trunk/lib/www/cgi.scm":326:(parse-content-disposition cd) > #?=field > #?- "form-data; name=a" > #?- ("form-data" #\; "name=a") > #?="/home/jens/down/scheme/gauche/svn/trunk/lib/www/cgi.scm":327:(member "name=" opts) > #?- #f > () > > ------------------------------------------------------------------------------ > SOLARIS 10 is the OS for Data Centers - provides features such as DTrace, > Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW > http://p.sf.net/sfu/solaris-dev2dev > _______________________________________________ > Gauche-devel mailing list > Gau...@li... > https://lists.sourceforge.net/lists/listinfo/gauche-devel |