commit
7bb5dd7c67
|
@ -1,6 +1,7 @@
|
||||||
#lang scribble/doc
|
#lang scribble/doc
|
||||||
@(require "common.ss"
|
@(require "common.ss"
|
||||||
(for-label net/cgi
|
(for-label net/cgi
|
||||||
|
net/uri-codec
|
||||||
net/cgi-unit
|
net/cgi-unit
|
||||||
net/cgi-sig))
|
net/cgi-sig))
|
||||||
|
|
||||||
|
@ -41,7 +42,10 @@ Returns the bindings that corresponding to the options specified by
|
||||||
the user. The @scheme[get-bindings/post] and
|
the user. The @scheme[get-bindings/post] and
|
||||||
@scheme[get-bindings/get] variants work only when POST and GET forms
|
@scheme[get-bindings/get] variants work only when POST and GET forms
|
||||||
are used, respectively, while @scheme[get-bindings] determines the
|
are used, respectively, while @scheme[get-bindings] determines the
|
||||||
kind of form that was used and invokes the appropriate function.}
|
kind of form that was used and invokes the appropriate function.
|
||||||
|
|
||||||
|
These functions respect @scheme[current-alist-separator-mode].
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@defproc[(extract-bindings [key? (or/c symbol? string?)]
|
@defproc[(extract-bindings [key? (or/c symbol? string?)]
|
||||||
|
|
50
collects/tests/net/cgi.ss
Normal file
50
collects/tests/net/cgi.ss
Normal file
|
@ -0,0 +1,50 @@
|
||||||
|
#lang scheme
|
||||||
|
(require net/cgi
|
||||||
|
net/uri-codec)
|
||||||
|
|
||||||
|
(define-syntax test-result
|
||||||
|
(syntax-rules ()
|
||||||
|
[(test-result expression expected)
|
||||||
|
(let ([result expression])
|
||||||
|
(if (equal? result expected)
|
||||||
|
(display (format "Ok: `~a' evaluated to `~a'.\n"
|
||||||
|
'expression expected))
|
||||||
|
(display (format
|
||||||
|
"Error: `~a' evaluated to `~a', expected `~a'.\n"
|
||||||
|
'expression result expected))))]))
|
||||||
|
|
||||||
|
(putenv "REQUEST_METHOD" "GET")
|
||||||
|
|
||||||
|
(test-result (begin
|
||||||
|
(current-alist-separator-mode 'amp-or-semi)
|
||||||
|
(putenv "QUERY_STRING" "key1=value1&key2=value2;key3=value3")
|
||||||
|
(get-bindings))
|
||||||
|
'((key1 . "value1")
|
||||||
|
(key2 . "value2")
|
||||||
|
(key3 . "value3")))
|
||||||
|
|
||||||
|
(test-result (begin
|
||||||
|
(current-alist-separator-mode 'amp)
|
||||||
|
(putenv "QUERY_STRING" "key1=value1&key2=value2")
|
||||||
|
(get-bindings))
|
||||||
|
'((key1 . "value1")
|
||||||
|
(key2 . "value2")))
|
||||||
|
|
||||||
|
(test-result (begin
|
||||||
|
(current-alist-separator-mode 'amp)
|
||||||
|
(putenv "QUERY_STRING" "key1=value1;key2=value2")
|
||||||
|
(get-bindings))
|
||||||
|
'((key1 . "value1;key2=value2")))
|
||||||
|
|
||||||
|
(test-result (begin
|
||||||
|
(current-alist-separator-mode 'semi)
|
||||||
|
(putenv "QUERY_STRING" "key1=value1;key2=value2")
|
||||||
|
(get-bindings))
|
||||||
|
'((key1 . "value1")
|
||||||
|
(key2 . "value2")))
|
||||||
|
|
||||||
|
(test-result (begin
|
||||||
|
(current-alist-separator-mode 'semi)
|
||||||
|
(putenv "QUERY_STRING" "key1=value1&key2=value2")
|
||||||
|
(get-bindings))
|
||||||
|
'((key1 . "value1&key2=value2")))
|
Loading…
Reference in New Issue
Block a user