blob: 21cc6870b775c551f5d2913753e1fb747c1e2478 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
(in-package #:scgi-routes/tests)
(5am:def-suite* scgi-routes-tests)
;;; Check variable binding
(5am:test variable-binding
(5am:finishes
(routes:define-route index (:path (p1 p2 "index.cgi")
:method :get
:query (q1
(q2 :init-form "2")
(q3 :name "named")
(q4 :name "all" :init-form "4"
:suppliedp q4p)
(q5 :suppliedp q5p))
:fragment f
:content-type "text/plain")
(list p1 p2 q1 q2 q3 q4 q4p q5 q5p f)))
(5am:is
(equal
(let (ret
(uri "http://localhost:8080/foo/blah/index.cgi?b=1&c=2&q5"))
(with-output-to-string (*standard-output*)
(setf ret (test-route :get uri)))
ret)
(list "foo" "blah" nil "2" nil "4" t nil t nil))))
(defun scgi-header (field-alist)
(let ((headers
(with-output-to-string (*standard-output*)
(dolist (entry field-alist)
(format t "~A~C~A~C" (car entry) #\Nul (cdr entry) #\Nul)))))
(concatenate 'string
(format nil "~D:" (length headers))
headers
(string #\Nul))))
;;; Check that unhandled exceptions don't crash the server
(5am:test condition-handling
(5am:finishes
(routes:define-route route-test2 (:path ("index.cgi")
:method :get)
(error "error-route-test2")))
(5am:finishes
(let ((header (scgi-header '(("SCGI" . "1")
("REQUEST_METHOD" . "GET")
("REQUEST_URI" . "/index.cgi")))))
(with-input-from-string (input header)
(with-output-to-string (output)
(let ((*error-output* output))
(routes::socket-function (make-two-way-stream input output)
#'routes::default-error-handler
#'routes::default-internal-error-handler)))))))
|