formCGI "POST" example
Posted: Sat Nov 02, 2002 2:09 am
;; cgi-post-test.lsp
;; modified formcgi.lsp from GET Method
;; to use POST method.
;;
(define (cgiexpand instr mode , test temp)
(set 'temp "")
(dolist (tmp (parse instr "%"))
(set 'test (substring tmp 0 2))
(set 'temp (concat temp (concat
(cond
((= "0D" test) (if mode "\r" ""))
((= "0A" test) (if mode "\n" "<br>"))
((= "21" test) "!")
((= "22" test) "\"")
((= "23" test) "#")
((= "24" test) "$")
((= "26" test) "&")
((= "27" test) "`")
((= "28" test) "(")
((= "29" test) ")")
((= "2C" test) ",")
((= "2D" test) "-")
((= "2F" test) "/")
((= "3A" test) ":")
((= "3B" test) ";")
((= "3C" test) "<")
((= "3D" test) "=")
((= "3E" test) ">")
((= "3F" test) "?")
((= "40" test) "@")
((= "5B" test) "[")
((= "5C" test) "\\")
((= "5D" test) "]")
((= "5E" test) "^")
((= "60" test) "'")
((= "7E" test) "~")
((= "7B" test) "{")
((= "7C" test) "|")
((= "7D" test) "}")
(true test))(substring tmp 2)))))
(replace "+" temp " ")
temp)
#
(define (cgigetargs input mode , outout x y z)
(if input
(begin
(set 'output '())
(replace "-" input "%2D")
(dolist (elmnt (parse input "&"))
(replace "=" elmnt " ")
(set 'output
(cons
(list (cgiexpand (first (parse elmnt)) mode)
(if (first (rest (parse elmnt)))
(cgiexpand (join (rest (parse elmnt))) mode) ""))) output)))
(reverse output))))
#
#
(print "Content-type: text/html\n\n")
(print "<h3>Form Variables</h3>\n")
(set 'input (read-line))
(print (cgigetargs input T))
#
(print "<p>Input = " input "<p>\n")
#
# command line arguments
(print "Command line = " (main-args) "<p>\n")
#
# print environment variables
(print "<h3>Environment Variables</h3>\n")
(dolist (env (environ)) (print env "<br>"))
(print "\n\n")
(exit)
#
;; modified formcgi.lsp from GET Method
;; to use POST method.
;;
(define (cgiexpand instr mode , test temp)
(set 'temp "")
(dolist (tmp (parse instr "%"))
(set 'test (substring tmp 0 2))
(set 'temp (concat temp (concat
(cond
((= "0D" test) (if mode "\r" ""))
((= "0A" test) (if mode "\n" "<br>"))
((= "21" test) "!")
((= "22" test) "\"")
((= "23" test) "#")
((= "24" test) "$")
((= "26" test) "&")
((= "27" test) "`")
((= "28" test) "(")
((= "29" test) ")")
((= "2C" test) ",")
((= "2D" test) "-")
((= "2F" test) "/")
((= "3A" test) ":")
((= "3B" test) ";")
((= "3C" test) "<")
((= "3D" test) "=")
((= "3E" test) ">")
((= "3F" test) "?")
((= "40" test) "@")
((= "5B" test) "[")
((= "5C" test) "\\")
((= "5D" test) "]")
((= "5E" test) "^")
((= "60" test) "'")
((= "7E" test) "~")
((= "7B" test) "{")
((= "7C" test) "|")
((= "7D" test) "}")
(true test))(substring tmp 2)))))
(replace "+" temp " ")
temp)
#
(define (cgigetargs input mode , outout x y z)
(if input
(begin
(set 'output '())
(replace "-" input "%2D")
(dolist (elmnt (parse input "&"))
(replace "=" elmnt " ")
(set 'output
(cons
(list (cgiexpand (first (parse elmnt)) mode)
(if (first (rest (parse elmnt)))
(cgiexpand (join (rest (parse elmnt))) mode) ""))) output)))
(reverse output))))
#
#
(print "Content-type: text/html\n\n")
(print "<h3>Form Variables</h3>\n")
(set 'input (read-line))
(print (cgigetargs input T))
#
(print "<p>Input = " input "<p>\n")
#
# command line arguments
(print "Command line = " (main-args) "<p>\n")
#
# print environment variables
(print "<h3>Environment Variables</h3>\n")
(dolist (env (environ)) (print env "<br>"))
(print "\n\n")
(exit)
#