fix read-post-request

cvs
Slava Pestov 2004-08-19 23:21:40 +00:00
parent 20491ce196
commit 17384f25cf
3 changed files with 13 additions and 7 deletions

View File

@ -69,14 +69,15 @@ USE: url-encoding
"Content-Length" swap assoc dec> ;
: post-request>alist ( post-request -- alist )
#! Return an alist containing name/value pairs from the
#! post data.
"&" split [ "=" split1 ] inject [
uncons >r url-decode r> url-decode cons
] inject ;
"&" split [ "=" split1 cons ] inject ;
: read-post-request ( header -- string )
content-length dup [ read# post-request>alist ] when ;
: url-decode-alist ( alist -- alist )
[ uncons >r url-decode r> url-decode cons ] inject ;
: read-post-request ( header -- alist )
content-length dup [
read# post-request>alist url-decode-alist
] when ;
: log-user-agent ( alist -- )
"User-Agent" swap assoc* [

View File

@ -46,6 +46,7 @@ USE: vectors
<% "This is " % java? [ "JVM " % ] when
native? [ "native " % ] when "Factor " % version % %> print
"Copyright (C) 2003, 2004 Slava Pestov" print
"Copyright (C) 2004 Chris Double" print
"Type ``exit'' to exit, ``help'' for help." print ;
: init-history ( -- )

View File

@ -62,3 +62,7 @@ USE: url-encoding
[ ] [ "GET /index.html" parse-request ] unit-test
[ ] [ "GET ../index.html" parse-request ] unit-test
[ ] [ "POO" parse-request ] unit-test
[ [ [ "Foo" | "Bar" ] ] ] [ "Foo=Bar" post-request>alist ] unit-test
[ [ [ "Foo" | "Bar" ] [ "Baz" | "Quux" ] ] ]
[ "Foo=Bar&Baz=Quux" post-request>alist ] unit-test