--- cgi.scm.orig Thu Jul 11 11:49:11 2002 +++ cgi.scm Fri Jul 5 19:17:46 2002 @@ -52,7 +52,7 @@ ;; (cgi:upload name) ;; (cgi:cookies name) ;; (cgi:cookie name) -;; (cgi:make-cookie value #&key path domain expires secure) +;; (cgi:make-cookie value #:key path domain expires secure) ;;; Code: @@ -124,7 +124,7 @@ ;; path associated with the cookie. ;; (cgi:cookies NAME) ;; Fetch the first cookie value associated with NAME. -;; (cgi:make-cookie NAME VALUE #&key path domain expires secure) +;; (cgi:make-cookie NAME VALUE #:key path domain expires secure) ;; Create a cookie suitable for inclusion into an HTTP response ;; header. Recognize optional parameters path, doman, expires, ;; (which should be strings) and secure (which is boolean). @@ -173,17 +173,18 @@ (and cookie-values (car cookie-values)))) (define-public cgi:make-cookie - (lambda* (name value #&key path domain expires secure) + (lambda* (name value #:key (path #f) (domain #f) + (expires #f) (secure #f)) (format #f "Set-Cookie: ~A=~A~A~A~A~A" name value - (if (bound? path) + (if path (format #f "; path=~A" path) "") - (if (bound? domain) + (if domain (format #f "; domain=~A" domain) "") - (if (bound? expires) + (if expires (format #f "; expires=~A" expires) "") - (if (and (bound? secure) secure) - "; secure" "")))) + (if secure + "; secure" "")))) @@ -203,10 +204,11 @@ ;; Values are URL-encoded, so url:decode must be called on each one. (define (get-name pair) (let ((p (string-index pair #\=))) - (and p (make-shared-substring pair 0 p)))) + (and p (substring pair 0 p)))) (define (get-value pair) (let ((p (string-index pair #\=))) - (and p (url:decode (make-shared-substring pair (+ p 1)))))) + (and p (url:decode (substring pair (+ p 1)))))) + (for-each (lambda (pair) (let* ((name (get-name pair)) (value (get-value pair)) @@ -376,8 +378,7 @@ (str str)) (let ((pos (string-rindex str ch))) (if pos - (loop (cons (make-shared-substring str (+ 1 pos)) fields) - (make-shared-substring str 0 pos)) - (cons str fields))))) + (loop (cons (substring str (+ 1 pos)) fields) + (substring str 0 pos)))))) ;;; www/cgi.scm ends here