Changeset 12023 in project
- Timestamp:
- 09/28/08 17:38:09 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
release/4/spiffy/trunk/spiffy.scm
r12022 r12023 38 38 (module spiffy 39 39 (start-server with-headers send-status send-static-file 40 41 root-path server-port index-files mime-type-map default-mime-type42 default-host43 handle-directory handle-not-found)40 current-request current-response current-file current-pathinfo 41 root-path server-port index-files mime-type-map default-mime-type default-host 42 handle-directory handle-not-found 43 restart-request) 44 44 45 45 (import chicken scheme extras ports files data-structures) … … 97 97 "The resource you requested could not be found")))) 98 98 99 100 ;;; Internal parameters 101 (define request-restarter (make-parameter #f)) 99 102 100 103 (define (send-status code reason #!optional text) … … 204 207 (current-request)))) 205 208 209 (define (restart-request req) 210 ((request-restarter) req (request-restarter))) 211 206 212 (define (handle-incoming-request in out) 207 213 (parameterize ((current-request (read-request in)) … … 211 217 `((content-type text/html)))))) 212 218 (let ((path (uri-path (request-uri (current-request))))) 213 (parameterize ((current-request (normalize-current-request-uri))) 214 (if (and (uri-host (request-uri (current-request))) (pair? path)) 215 (process-entry "" path) 216 ;; No host in the request? That's an error. 217 (send-status 400 "Bad request" 218 "Your client sent a request that the server did not understand"))) 219 (receive (req cont) 220 (call/cc (lambda (c) (values (normalize-current-request-uri) c))) 221 (parameterize ((current-request req) 222 (request-restarter cont)) 223 (if (and (uri-host (request-uri (current-request))) (pair? path)) 224 (process-entry "" path) 225 ;; No host in the request? That's an error. 226 (send-status 400 "Bad request" 227 "Your client sent a request that the server did not understand")))) 219 228 ;; For now, just close the ports and allow the thread to exit 220 229 (close-output-port out)
Note: See TracChangeset
for help on using the changeset viewer.