Adding better contracts and renaming in accordance w/ Robbys suggestion
svn: r11428
This commit is contained in:
parent
354ebabe0c
commit
4e764d8f0e
|
@ -30,16 +30,14 @@
|
||||||
additional-names))
|
additional-names))
|
||||||
new-namespace)))
|
new-namespace)))
|
||||||
|
|
||||||
; XXX
|
(define make-servlet-namespace/c
|
||||||
(define module-spec? any/c)
|
|
||||||
(define make-servlet-namespace?
|
|
||||||
(->* ()
|
(->* ()
|
||||||
(#:additional-specs (listof module-spec?))
|
(#:additional-specs (listof module-path?))
|
||||||
namespace?))
|
namespace?))
|
||||||
|
|
||||||
(provide/contract
|
(provide/contract
|
||||||
[make-servlet-namespace? contract?]
|
[make-servlet-namespace/c contract?]
|
||||||
[make-make-servlet-namespace
|
[make-make-servlet-namespace
|
||||||
(->* ()
|
(->* ()
|
||||||
(#:to-be-copied-module-specs (listof module-spec?))
|
(#:to-be-copied-module-specs (listof module-path?))
|
||||||
make-servlet-namespace?)])
|
make-servlet-namespace/c)])
|
||||||
|
|
|
@ -13,15 +13,13 @@
|
||||||
"../dispatchers/filesystem-map.ss")
|
"../dispatchers/filesystem-map.ss")
|
||||||
|
|
||||||
(provide/contract
|
(provide/contract
|
||||||
[interface-version dispatcher-interface-version?]
|
[interface-version dispatcher-interface-version/c]
|
||||||
[read-range-header (-> (listof header?) (or/c (listof pair?) false/c))])
|
[read-range-header (-> (listof header?) (or/c (listof pair?) false/c))]
|
||||||
|
|
||||||
(provide/contract
|
|
||||||
[make
|
[make
|
||||||
(->* (#:url->path url-path?)
|
(->* (#:url->path url-path/c)
|
||||||
(#:path->mime-type (path? . -> . bytes?)
|
(#:path->mime-type (path? . -> . bytes?)
|
||||||
#:indices (listof path-string?))
|
#:indices (listof path-string?))
|
||||||
dispatcher?)])
|
dispatcher/c)])
|
||||||
|
|
||||||
;; looks-like-directory : str -> bool
|
;; looks-like-directory : str -> bool
|
||||||
;; to determine if is url style path looks like it refers to a directory
|
;; to determine if is url style path looks like it refers to a directory
|
||||||
|
|
|
@ -5,8 +5,8 @@
|
||||||
"../private/request-structs.ss"
|
"../private/request-structs.ss"
|
||||||
"../private/util.ss")
|
"../private/util.ss")
|
||||||
(provide/contract
|
(provide/contract
|
||||||
[interface-version dispatcher-interface-version?]
|
[interface-version dispatcher-interface-version/c]
|
||||||
[make (regexp? dispatcher? . -> . dispatcher?)])
|
[make (regexp? dispatcher/c . -> . dispatcher/c)])
|
||||||
|
|
||||||
(define interface-version 'v1)
|
(define interface-version 'v1)
|
||||||
(define ((make regex inner) conn req)
|
(define ((make regex inner) conn req)
|
||||||
|
|
|
@ -6,8 +6,8 @@
|
||||||
"../private/util.ss"
|
"../private/util.ss"
|
||||||
"dispatch.ss")
|
"dispatch.ss")
|
||||||
(provide/contract
|
(provide/contract
|
||||||
[interface-version dispatcher-interface-version?]
|
[interface-version dispatcher-interface-version/c]
|
||||||
[make ((symbol? . -> . dispatcher?) . -> . dispatcher?)])
|
[make ((symbol? . -> . dispatcher/c) . -> . dispatcher/c)])
|
||||||
|
|
||||||
(define interface-version 'v1)
|
(define interface-version 'v1)
|
||||||
(define ((make lookup-dispatcher) conn req)
|
(define ((make lookup-dispatcher) conn req)
|
||||||
|
|
|
@ -17,13 +17,13 @@
|
||||||
"../configuration/responders.ss")
|
"../configuration/responders.ss")
|
||||||
|
|
||||||
(provide/contract
|
(provide/contract
|
||||||
[interface-version dispatcher-interface-version?]
|
[interface-version dispatcher-interface-version/c]
|
||||||
[make
|
[make
|
||||||
(->* (#:url->path url-path?)
|
(->* (#:url->path url-path/c)
|
||||||
(#:make-servlet-namespace make-servlet-namespace?
|
(#:make-servlet-namespace make-servlet-namespace/c
|
||||||
#:responders-servlet-loading (url? any/c . -> . response?)
|
#:responders-servlet-loading (url? any/c . -> . response?)
|
||||||
#:responders-servlet (url? any/c . -> . response?))
|
#:responders-servlet (url? any/c . -> . response?))
|
||||||
dispatcher?)])
|
dispatcher/c)])
|
||||||
|
|
||||||
; XXX url->servlet
|
; XXX url->servlet
|
||||||
; XXX optional session manager
|
; XXX optional session manager
|
||||||
|
|
|
@ -5,8 +5,8 @@
|
||||||
"../private/request-structs.ss"
|
"../private/request-structs.ss"
|
||||||
"../private/response-structs.ss")
|
"../private/response-structs.ss")
|
||||||
(provide/contract
|
(provide/contract
|
||||||
[interface-version dispatcher-interface-version?]
|
[interface-version dispatcher-interface-version/c]
|
||||||
[make ((request? . -> . response?) . -> . dispatcher?)])
|
[make ((request? . -> . response?) . -> . dispatcher/c)])
|
||||||
|
|
||||||
(define interface-version 'v1)
|
(define interface-version 'v1)
|
||||||
(define ((make procedure) conn req)
|
(define ((make procedure) conn req)
|
||||||
|
|
|
@ -15,11 +15,11 @@
|
||||||
[paren-format format-req/c]
|
[paren-format format-req/c]
|
||||||
[extended-format format-req/c]
|
[extended-format format-req/c]
|
||||||
[apache-default-format format-req/c]
|
[apache-default-format format-req/c]
|
||||||
[interface-version dispatcher-interface-version?]
|
[interface-version dispatcher-interface-version/c]
|
||||||
[make (->* ()
|
[make (->* ()
|
||||||
(#:format format-req/c
|
(#:format format-req/c
|
||||||
#:log-path path-string?)
|
#:log-path path-string?)
|
||||||
dispatcher?)])
|
dispatcher/c)])
|
||||||
|
|
||||||
(define interface-version 'v1)
|
(define interface-version 'v1)
|
||||||
(define (make #:format [format paren-format]
|
(define (make #:format [format paren-format]
|
||||||
|
|
|
@ -10,14 +10,14 @@
|
||||||
"../servlet/basic-auth.ss"
|
"../servlet/basic-auth.ss"
|
||||||
"../private/response.ss")
|
"../private/response.ss")
|
||||||
(provide/contract
|
(provide/contract
|
||||||
[interface-version dispatcher-interface-version?]
|
[interface-version dispatcher-interface-version/c]
|
||||||
[make (->* ()
|
[make (->* ()
|
||||||
(#:password-file path-string?
|
(#:password-file path-string?
|
||||||
#:authentication-responder
|
#:authentication-responder
|
||||||
(url? header? . -> . response?))
|
(url? header? . -> . response?))
|
||||||
(values
|
(values
|
||||||
(-> void)
|
(-> void)
|
||||||
dispatcher?))])
|
dispatcher/c))])
|
||||||
|
|
||||||
(define interface-version 'v1)
|
(define interface-version 'v1)
|
||||||
(define (make ; XXX Take authorized? function
|
(define (make ; XXX Take authorized? function
|
||||||
|
|
|
@ -7,8 +7,8 @@
|
||||||
"../private/request-structs.ss"
|
"../private/request-structs.ss"
|
||||||
"../private/response-structs.ss")
|
"../private/response-structs.ss")
|
||||||
(provide/contract
|
(provide/contract
|
||||||
[interface-version dispatcher-interface-version?]
|
[interface-version dispatcher-interface-version/c]
|
||||||
[make (string? (request? . -> . response?) . -> . dispatcher?)])
|
[make (string? (request? . -> . response?) . -> . dispatcher/c)])
|
||||||
|
|
||||||
(define interface-version 'v1)
|
(define interface-version 'v1)
|
||||||
(define ((make the-path procedure) conn req)
|
(define ((make the-path procedure) conn req)
|
||||||
|
|
|
@ -1,10 +1,8 @@
|
||||||
#lang scheme/base
|
#lang scheme
|
||||||
(require mzlib/list
|
|
||||||
mzlib/contract)
|
|
||||||
(require "dispatch.ss")
|
(require "dispatch.ss")
|
||||||
(provide/contract
|
(provide/contract
|
||||||
[interface-version dispatcher-interface-version?])
|
[interface-version dispatcher-interface-version/c]
|
||||||
(provide make)
|
[make (() () #:rest (listof dispatcher/c) . ->* . dispatcher/c)])
|
||||||
|
|
||||||
(define interface-version 'v1)
|
(define interface-version 'v1)
|
||||||
(define ((make . dispatchers) conn req)
|
(define ((make . dispatchers) conn req)
|
||||||
|
|
|
@ -19,15 +19,15 @@
|
||||||
"../private/cache-table.ss"
|
"../private/cache-table.ss"
|
||||||
"../private/util.ss")
|
"../private/util.ss")
|
||||||
(provide/contract
|
(provide/contract
|
||||||
[interface-version dispatcher-interface-version?]
|
[interface-version dispatcher-interface-version/c]
|
||||||
[make (->* ((box/c cache-table?)
|
[make (->* ((box/c cache-table?)
|
||||||
#:url->path url-path?)
|
#:url->path url-path/c)
|
||||||
(#:make-servlet-namespace make-servlet-namespace?
|
(#:make-servlet-namespace make-servlet-namespace/c
|
||||||
#:responders-servlet-loading (url? any/c . -> . response?)
|
#:responders-servlet-loading (url? any/c . -> . response?)
|
||||||
#:responders-servlet (url? any/c . -> . response?)
|
#:responders-servlet (url? any/c . -> . response?)
|
||||||
#:timeouts-default-servlet number?)
|
#:timeouts-default-servlet number?)
|
||||||
(values (-> void)
|
(values (-> void)
|
||||||
dispatcher?))])
|
dispatcher/c))])
|
||||||
|
|
||||||
(define interface-version 'v1)
|
(define interface-version 'v1)
|
||||||
(define (make config:scripts
|
(define (make config:scripts
|
||||||
|
|
|
@ -5,8 +5,8 @@
|
||||||
"../private/connection-manager.ss")
|
"../private/connection-manager.ss")
|
||||||
(provide/contract
|
(provide/contract
|
||||||
[make-gc-thread (integer? . -> . thread?)]
|
[make-gc-thread (integer? . -> . thread?)]
|
||||||
[interface-version dispatcher-interface-version?]
|
[interface-version dispatcher-interface-version/c]
|
||||||
[make (-> dispatcher?)])
|
[make (-> dispatcher/c)])
|
||||||
|
|
||||||
(define (bytes->mb b)
|
(define (bytes->mb b)
|
||||||
(round (exact->inexact (/ b 1024 1024))))
|
(round (exact->inexact (/ b 1024 1024))))
|
||||||
|
|
|
@ -3,8 +3,8 @@
|
||||||
(require "dispatch.ss"
|
(require "dispatch.ss"
|
||||||
"../private/connection-manager.ss")
|
"../private/connection-manager.ss")
|
||||||
(provide/contract
|
(provide/contract
|
||||||
[interface-version dispatcher-interface-version?]
|
[interface-version dispatcher-interface-version/c]
|
||||||
[make (integer? . -> . dispatcher?)])
|
[make (integer? . -> . dispatcher/c)])
|
||||||
|
|
||||||
(define interface-version 'v1)
|
(define interface-version 'v1)
|
||||||
(define ((make new-timeout) conn req)
|
(define ((make new-timeout) conn req)
|
||||||
|
|
|
@ -1,17 +1,17 @@
|
||||||
#lang scheme/base
|
#lang scheme/base
|
||||||
(require mzlib/contract)
|
(require scheme/contract)
|
||||||
(require "../private/connection-manager.ss"
|
(require "../private/connection-manager.ss"
|
||||||
"../private/request-structs.ss")
|
"../private/request-structs.ss")
|
||||||
|
|
||||||
(define dispatcher?
|
(define dispatcher/c
|
||||||
(connection? request? . -> . void))
|
(connection? request? . -> . void))
|
||||||
(define (dispatcher-interface-version? v)
|
(define dispatcher-interface-version/c
|
||||||
(and (symbol? v) (eq? v 'v1)))
|
(symbols 'v1))
|
||||||
(define-struct exn:dispatcher ())
|
(define-struct exn:dispatcher ())
|
||||||
(define (next-dispatcher) (raise (make-exn:dispatcher)))
|
(define (next-dispatcher) (raise (make-exn:dispatcher)))
|
||||||
|
|
||||||
(provide/contract
|
(provide/contract
|
||||||
[dispatcher? contract?]
|
[dispatcher/c contract?]
|
||||||
[dispatcher-interface-version? (any/c . -> . boolean?)]
|
[dispatcher-interface-version/c contract?]
|
||||||
[next-dispatcher (-> void)]
|
[next-dispatcher (-> void)]
|
||||||
[struct exn:dispatcher ()])
|
[struct exn:dispatcher ()])
|
||||||
|
|
|
@ -3,13 +3,13 @@
|
||||||
mzlib/list
|
mzlib/list
|
||||||
mzlib/contract)
|
mzlib/contract)
|
||||||
(require "../private/util.ss")
|
(require "../private/util.ss")
|
||||||
(define url-path?
|
(define url-path/c
|
||||||
((url?) . ->* . (path? (listof path-element?))))
|
((url?) . ->* . (path? (listof path-element?))))
|
||||||
|
|
||||||
(provide/contract
|
(provide/contract
|
||||||
[url-path? contract?]
|
[url-path/c contract?]
|
||||||
[make-url->path (path? . -> . url-path?)]
|
[make-url->path (path? . -> . url-path/c)]
|
||||||
[make-url->valid-path (url-path? . -> . url-path?)])
|
[make-url->valid-path (url-path/c . -> . url-path/c)])
|
||||||
|
|
||||||
(define (build-path* . l)
|
(define (build-path* . l)
|
||||||
(if (empty? l)
|
(if (empty? l)
|
||||||
|
|
|
@ -13,14 +13,15 @@
|
||||||
(define launch-browser? #t)
|
(define launch-browser? #t)
|
||||||
|
|
||||||
(provide/contract
|
(provide/contract
|
||||||
(static-files-path ((or/c string? path?) . -> . void?)))
|
[static-files-path ((or/c string? path?) . -> . void?)])
|
||||||
(define (static-files-path path)
|
(define (static-files-path path)
|
||||||
(set! extra-files-path
|
(set! extra-files-path
|
||||||
(if (path? path)
|
(if (path? path)
|
||||||
path
|
path
|
||||||
(string->path path))))
|
(string->path path))))
|
||||||
|
|
||||||
(provide no-web-browser)
|
(provide/contract
|
||||||
|
[no-web-browser (-> void)])
|
||||||
(define (no-web-browser)
|
(define (no-web-browser)
|
||||||
(set! launch-browser? false))
|
(set! launch-browser? false))
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
mzlib/serialize
|
mzlib/serialize
|
||||||
"../private/define-closure.ss"
|
"../private/define-closure.ss"
|
||||||
"../lang/web-cells.ss")
|
"../lang/web-cells.ss")
|
||||||
|
; XXX contract
|
||||||
(provide
|
(provide
|
||||||
|
|
||||||
;; AUXILLIARIES
|
;; AUXILLIARIES
|
||||||
|
|
|
@ -2,9 +2,11 @@
|
||||||
(require (for-template scheme/base)
|
(require (for-template scheme/base)
|
||||||
syntax/kerncase
|
syntax/kerncase
|
||||||
mzlib/list
|
mzlib/list
|
||||||
|
scheme/contract
|
||||||
mzlib/plt-match
|
mzlib/plt-match
|
||||||
"util.ss")
|
"util.ss")
|
||||||
(provide make-anormal-term)
|
(provide/contract
|
||||||
|
[make-anormal-term ((syntax? . -> . syntax?) . -> . (syntax? . -> . syntax?))])
|
||||||
|
|
||||||
; A-Normal Form
|
; A-Normal Form
|
||||||
(define (id x) x)
|
(define (id x) x)
|
||||||
|
|
|
@ -2,11 +2,13 @@
|
||||||
(require (for-template scheme/base)
|
(require (for-template scheme/base)
|
||||||
syntax/kerncase
|
syntax/kerncase
|
||||||
syntax/free-vars
|
syntax/free-vars
|
||||||
|
scheme/contract
|
||||||
mzlib/list
|
mzlib/list
|
||||||
mzlib/plt-match
|
mzlib/plt-match
|
||||||
"util.ss"
|
"util.ss"
|
||||||
"../private/closure.ss")
|
"../private/closure.ss")
|
||||||
(provide defun)
|
(provide/contract
|
||||||
|
[defun (syntax? . -> . (values syntax? (listof syntax?)))])
|
||||||
|
|
||||||
; make-new-clouse-label : (syntax -> syntax) syntax -> syntax
|
; make-new-clouse-label : (syntax -> syntax) syntax -> syntax
|
||||||
(define (make-new-closure-label labeling stx)
|
(define (make-new-closure-label labeling stx)
|
||||||
|
|
|
@ -1,10 +1,12 @@
|
||||||
#lang scheme/base
|
#lang scheme/base
|
||||||
(require (for-template scheme/base)
|
(require (for-template scheme/base)
|
||||||
syntax/kerncase
|
syntax/kerncase
|
||||||
|
scheme/contract
|
||||||
"../lang/abort-resume.ss"
|
"../lang/abort-resume.ss"
|
||||||
(for-template "../lang/abort-resume.ss")
|
(for-template "../lang/abort-resume.ss")
|
||||||
"util.ss")
|
"util.ss")
|
||||||
(provide elim-callcc)
|
(provide/contract
|
||||||
|
[elim-callcc (syntax? . -> . syntax?)])
|
||||||
|
|
||||||
(define (id x) x)
|
(define (id x) x)
|
||||||
|
|
||||||
|
|
|
@ -3,9 +3,12 @@
|
||||||
syntax/kerncase
|
syntax/kerncase
|
||||||
mzlib/etc
|
mzlib/etc
|
||||||
mzlib/list
|
mzlib/list
|
||||||
|
scheme/contract
|
||||||
(for-template "../lang/abort-resume.ss")
|
(for-template "../lang/abort-resume.ss")
|
||||||
"util.ss")
|
"util.ss")
|
||||||
(provide (all-defined-out))
|
(provide/contract
|
||||||
|
[elim-letrec ((listof syntax?) . -> . (syntax? . -> . syntax?))]
|
||||||
|
[elim-letrec-term (syntax? . -> . syntax?)])
|
||||||
|
|
||||||
; elim-letrec : (listof identifier-syntax?)[3] -> syntax?[2] -> syntax?[3]
|
; elim-letrec : (listof identifier-syntax?)[3] -> syntax?[2] -> syntax?[3]
|
||||||
; Eliminates letrec-values from syntax[2] and correctly handles references to
|
; Eliminates letrec-values from syntax[2] and correctly handles references to
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#lang scheme/base
|
#lang scheme
|
||||||
(require mzlib/md5)
|
(require mzlib/md5)
|
||||||
(provide make-labeling)
|
(provide/contract
|
||||||
|
[make-labeling (bytes? . -> . (-> symbol?))])
|
||||||
|
|
||||||
;; REQUIREMENT: The label code must be non-numeric.
|
;; REQUIREMENT: The label code must be non-numeric.
|
||||||
;; REQUIREMENT: The first numeric character following the label code
|
;; REQUIREMENT: The first numeric character following the label code
|
||||||
|
|
|
@ -1,9 +1,12 @@
|
||||||
#lang scheme/base
|
#lang scheme/base
|
||||||
(require net/url
|
(require net/url
|
||||||
|
scheme/contract
|
||||||
(for-template "web.ss")
|
(for-template "web.ss")
|
||||||
"web.ss"
|
"web.ss"
|
||||||
|
web-server/private/request-structs
|
||||||
"../servlet/helpers.ss")
|
"../servlet/helpers.ss")
|
||||||
(provide redirect/get)
|
(provide/contract
|
||||||
|
[redirect/get (-> request?)])
|
||||||
|
|
||||||
(define (redirect/get)
|
(define (redirect/get)
|
||||||
(send/suspend/url (lambda (k-url) (redirect-to (url->string k-url) temporarily))))
|
(send/suspend/url (lambda (k-url) (redirect-to (url->string k-url) temporarily))))
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
#lang scheme/base
|
#lang scheme/base
|
||||||
(require (for-syntax scheme/base)
|
(require (for-syntax scheme/base)
|
||||||
|
scheme/contract
|
||||||
"../private/closure.ss"
|
"../private/closure.ss"
|
||||||
mzlib/list)
|
mzlib/list)
|
||||||
|
|
||||||
; XXX Add contract
|
(provide/contract
|
||||||
|
[web-parameter? (any/c . -> . boolean?)])
|
||||||
(provide make-web-parameter
|
(provide make-web-parameter
|
||||||
web-parameter?
|
|
||||||
web-parameterize)
|
web-parameterize)
|
||||||
|
|
||||||
(define (web-parameter? any)
|
(define (web-parameter? any)
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
#lang scheme
|
#lang scheme
|
||||||
(require net/url
|
(require net/url
|
||||||
|
scheme/contract
|
||||||
scheme/serialize
|
scheme/serialize
|
||||||
|
web-server/private/request-structs
|
||||||
|
web-server/private/response-structs
|
||||||
web-server/private/define-closure
|
web-server/private/define-closure
|
||||||
"../private/request-structs.ss"
|
"../private/request-structs.ss"
|
||||||
"abort-resume.ss"
|
"abort-resume.ss"
|
||||||
|
@ -8,7 +11,7 @@
|
||||||
"stuff-url.ss"
|
"stuff-url.ss"
|
||||||
"../private/url-param.ss")
|
"../private/url-param.ss")
|
||||||
|
|
||||||
(provide
|
(provide
|
||||||
;; Server Interface
|
;; Server Interface
|
||||||
initialize-servlet
|
initialize-servlet
|
||||||
|
|
||||||
|
@ -17,6 +20,17 @@
|
||||||
send/suspend/url
|
send/suspend/url
|
||||||
send/suspend/dispatch)
|
send/suspend/dispatch)
|
||||||
|
|
||||||
|
; These contracts interfere with the continuation safety marks
|
||||||
|
#;(provide/contract
|
||||||
|
;; Server Interface
|
||||||
|
[initialize-servlet ((request? . -> . response?) . -> . (request? . -> . response?))]
|
||||||
|
|
||||||
|
;; Servlet Interface
|
||||||
|
[send/suspend/hidden ((url? list? . -> . response?) . -> . request?)]
|
||||||
|
[send/suspend/url ((url? . -> . response?) . -> . request?)]
|
||||||
|
[send/suspend/dispatch ((((request? . -> . any/c) . -> . url?) . -> . response?)
|
||||||
|
. -> . any/c)])
|
||||||
|
|
||||||
;; initial-servlet : (request -> response) -> (request -> response?)
|
;; initial-servlet : (request -> response) -> (request -> response?)
|
||||||
(define (initialize-servlet start)
|
(define (initialize-servlet start)
|
||||||
(let ([params (current-parameterization)])
|
(let ([params (current-parameterization)])
|
||||||
|
|
|
@ -4,11 +4,11 @@
|
||||||
(require "manager.ss"
|
(require "manager.ss"
|
||||||
"../servlet/servlet-structs.ss")
|
"../servlet/servlet-structs.ss")
|
||||||
(provide/contract
|
(provide/contract
|
||||||
[create-LRU-manager (expiration-handler? number? number? (-> boolean?)
|
[create-LRU-manager (expiration-handler/c number? number? (-> boolean?)
|
||||||
#:initial-count number?
|
#:initial-count number?
|
||||||
#:inform-p (number? . -> . void)
|
#:inform-p (number? . -> . void)
|
||||||
. -> . manager?)]
|
. -> . manager?)]
|
||||||
[make-threshold-LRU-manager (expiration-handler? number? . -> . manager?)])
|
[make-threshold-LRU-manager (expiration-handler/c number? . -> . manager?)])
|
||||||
|
|
||||||
;; Utility
|
;; Utility
|
||||||
(define (make-counter)
|
(define (make-counter)
|
||||||
|
|
|
@ -18,13 +18,13 @@
|
||||||
[struct manager ([create-instance ((-> void) . -> . number?)]
|
[struct manager ([create-instance ((-> void) . -> . number?)]
|
||||||
[adjust-timeout! (number? number? . -> . void)]
|
[adjust-timeout! (number? number? . -> . void)]
|
||||||
[clear-continuations! (number? . -> . void)]
|
[clear-continuations! (number? . -> . void)]
|
||||||
[continuation-store! (number? any/c expiration-handler? . -> . (list/c number? number?))]
|
[continuation-store! (number? any/c expiration-handler/c . -> . (list/c number? number?))]
|
||||||
[continuation-lookup (number? number? number? . -> . any/c)])]
|
[continuation-lookup (number? number? number? . -> . any/c)])]
|
||||||
[struct (exn:fail:servlet-manager:no-instance exn:fail)
|
[struct (exn:fail:servlet-manager:no-instance exn:fail)
|
||||||
([message string?]
|
([message string?]
|
||||||
[continuation-marks continuation-mark-set?]
|
[continuation-marks continuation-mark-set?]
|
||||||
[expiration-handler expiration-handler?])]
|
[expiration-handler expiration-handler/c])]
|
||||||
[struct (exn:fail:servlet-manager:no-continuation exn:fail)
|
[struct (exn:fail:servlet-manager:no-continuation exn:fail)
|
||||||
([message string?]
|
([message string?]
|
||||||
[continuation-marks continuation-mark-set?]
|
[continuation-marks continuation-mark-set?]
|
||||||
[expiration-handler expiration-handler?])])
|
[expiration-handler expiration-handler/c])])
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
(require "manager.ss")
|
(require "manager.ss")
|
||||||
(require "../servlet/servlet-structs.ss")
|
(require "../servlet/servlet-structs.ss")
|
||||||
(provide/contract
|
(provide/contract
|
||||||
[create-none-manager (expiration-handler? . -> . manager?)])
|
[create-none-manager (expiration-handler/c . -> . manager?)])
|
||||||
|
|
||||||
(define-struct (none-manager manager) (instance-expiration-handler))
|
(define-struct (none-manager manager) (instance-expiration-handler))
|
||||||
(define (create-none-manager
|
(define (create-none-manager
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
(require "../private/timer.ss"
|
(require "../private/timer.ss"
|
||||||
"../servlet/servlet-structs.ss")
|
"../servlet/servlet-structs.ss")
|
||||||
(provide/contract
|
(provide/contract
|
||||||
[create-timeout-manager (expiration-handler? number? number? . -> . manager?)])
|
[create-timeout-manager (expiration-handler/c number? number? . -> . manager?)])
|
||||||
|
|
||||||
;; Utility
|
;; Utility
|
||||||
(define (make-counter)
|
(define (make-counter)
|
||||||
|
|
|
@ -2,9 +2,11 @@
|
||||||
(require (for-template scheme/base)
|
(require (for-template scheme/base)
|
||||||
(for-template mzlib/serialize)
|
(for-template mzlib/serialize)
|
||||||
mzlib/list
|
mzlib/list
|
||||||
|
scheme/contract
|
||||||
mzlib/serialize)
|
mzlib/serialize)
|
||||||
(provide make-closure-definition-syntax
|
(provide/contract
|
||||||
closure->deserialize-name)
|
[closure->deserialize-name (serializable? . -> . symbol?)])
|
||||||
|
(provide make-closure-definition-syntax)
|
||||||
|
|
||||||
(define (closure->deserialize-name proc)
|
(define (closure->deserialize-name proc)
|
||||||
(cdr (first (third (serialize proc)))))
|
(cdr (first (third (serialize proc)))))
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
#lang scheme/unit
|
#lang scheme/unit
|
||||||
(require net/tcp-sig
|
(require net/tcp-sig
|
||||||
mzlib/thread
|
mzlib/thread)
|
||||||
mzlib/contract
|
|
||||||
mzlib/kw)
|
|
||||||
(require "web-server-structs.ss"
|
(require "web-server-structs.ss"
|
||||||
"connection-manager.ss"
|
"connection-manager.ss"
|
||||||
"dispatch-server-sig.ss")
|
"dispatch-server-sig.ss")
|
||||||
|
@ -56,9 +54,8 @@
|
||||||
|
|
||||||
;; handle-connection : input-port output-port (input-port -> string string) -> void
|
;; handle-connection : input-port output-port (input-port -> string string) -> void
|
||||||
;; returns immediately, spawning a thread to handle
|
;; returns immediately, spawning a thread to handle
|
||||||
(define/kw (handle-connection ip op
|
(define (handle-connection ip op
|
||||||
#:optional
|
#:port-addresses [port-addresses tcp-addresses])
|
||||||
[port-addresses tcp-addresses])
|
|
||||||
(define conn
|
(define conn
|
||||||
(new-connection config:initial-connection-timeout
|
(new-connection config:initial-connection-timeout
|
||||||
ip op (current-custodian) #f))
|
ip op (current-custodian) #f))
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#lang scheme/base
|
#lang scheme/base
|
||||||
(require mzlib/list
|
(require mzlib/list
|
||||||
mzlib/plt-match)
|
mzlib/plt-match)
|
||||||
|
; XXX Contract?
|
||||||
(provide compress-serial
|
(provide compress-serial
|
||||||
decompress-serial)
|
decompress-serial)
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,8 @@
|
||||||
"../private/request-structs.ss")
|
"../private/request-structs.ss")
|
||||||
|
|
||||||
(provide/contract
|
(provide/contract
|
||||||
[rename ext:read-request read-request ((connection? number? ((input-port?) . ->* . (string? string?))) . ->* . (request? boolean?))])
|
[rename ext:read-request read-request
|
||||||
|
((connection? number? ((input-port?) . ->* . (string? string?))) . ->* . (request? boolean?))])
|
||||||
|
|
||||||
(define (ext:read-request conn host-port port-addresses)
|
(define (ext:read-request conn host-port port-addresses)
|
||||||
(with-handlers ([exn? (lambda (exn)
|
(with-handlers ([exn? (lambda (exn)
|
||||||
|
|
|
@ -1,12 +1,10 @@
|
||||||
#lang scheme/base
|
#lang scheme/base
|
||||||
(require mzlib/contract)
|
(require scheme/contract)
|
||||||
(require "../managers/manager.ss"
|
(require "../managers/manager.ss"
|
||||||
"../private/request-structs.ss"
|
"../private/request-structs.ss"
|
||||||
"../private/response-structs.ss")
|
"../private/response-structs.ss")
|
||||||
|
|
||||||
(define servlet-prompt (make-continuation-prompt-tag 'servlet))
|
(define servlet-prompt (make-continuation-prompt-tag 'servlet))
|
||||||
(provide servlet-prompt)
|
|
||||||
|
|
||||||
(define-struct (exn:fail:servlet:instance exn:fail) ()
|
(define-struct (exn:fail:servlet:instance exn:fail) ()
|
||||||
#:mutable)
|
#:mutable)
|
||||||
(define-struct servlet (custodian namespace manager handler)
|
(define-struct servlet (custodian namespace manager handler)
|
||||||
|
@ -22,6 +20,7 @@
|
||||||
(servlet-manager (current-servlet)))
|
(servlet-manager (current-servlet)))
|
||||||
|
|
||||||
(provide/contract
|
(provide/contract
|
||||||
|
[servlet-prompt continuation-prompt-tag?]
|
||||||
[struct (exn:fail:servlet:instance exn:fail)
|
[struct (exn:fail:servlet:instance exn:fail)
|
||||||
([message string?]
|
([message string?]
|
||||||
[continuation-marks continuation-mark-set?])]
|
[continuation-marks continuation-mark-set?])]
|
||||||
|
@ -32,7 +31,7 @@
|
||||||
[handler (request? . -> . response?)])]
|
[handler (request? . -> . response?)])]
|
||||||
[struct execution-context
|
[struct execution-context
|
||||||
([request request?])]
|
([request request?])]
|
||||||
[current-servlet parameter?]
|
[current-servlet (parameter/c servlet?)]
|
||||||
[current-servlet-instance-id parameter?]
|
[current-servlet-instance-id (parameter/c number?)]
|
||||||
[current-execution-context parameter?]
|
[current-execution-context (parameter/c execution-context?)]
|
||||||
[current-servlet-manager (-> manager?)])
|
[current-servlet-manager (-> manager?)])
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#lang scheme/base
|
#lang scheme/base
|
||||||
(require mzlib/contract
|
(require scheme/contract
|
||||||
mzlib/list
|
mzlib/list
|
||||||
net/url
|
net/url
|
||||||
"response-structs.ss"
|
"response-structs.ss"
|
||||||
|
@ -32,8 +32,8 @@
|
||||||
[url url?])]
|
[url url?])]
|
||||||
[lookup-session ((listof string?) . -> . (or/c session? false/c))]
|
[lookup-session ((listof string?) . -> . (or/c session? false/c))]
|
||||||
[install-session (session? (listof string?) . -> . void)]
|
[install-session (session? (listof string?) . -> . void)]
|
||||||
[new-session (custodian? namespace? url? (listof string?) . -> . session?)])
|
[new-session (custodian? namespace? url? (listof string?) . -> . session?)]
|
||||||
(provide current-session)
|
[current-session (parameter/c session?)])
|
||||||
|
|
||||||
(define current-session (make-parameter #f))
|
(define current-session (make-parameter #f))
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
(require mzlib/contract)
|
(require mzlib/contract)
|
||||||
|
|
||||||
(define current-server-custodian (make-parameter #f))
|
(define current-server-custodian (make-parameter #f))
|
||||||
(provide current-server-custodian) ; parameter
|
|
||||||
|
|
||||||
;; make-servlet-custodian: -> custodian
|
;; make-servlet-custodian: -> custodian
|
||||||
;; create a custodian for the dynamic extent of a servlet continuation
|
;; create a custodian for the dynamic extent of a servlet continuation
|
||||||
|
@ -10,4 +9,5 @@
|
||||||
(make-custodian (current-server-custodian)))
|
(make-custodian (current-server-custodian)))
|
||||||
|
|
||||||
(provide/contract
|
(provide/contract
|
||||||
|
[current-server-custodian (parameter/c custodian?)]
|
||||||
[make-servlet-custodian (-> custodian?)])
|
[make-servlet-custodian (-> custodian?)])
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#lang scheme/base
|
#lang scheme/base
|
||||||
(require net/url
|
(require net/url
|
||||||
mzlib/plt-match)
|
mzlib/plt-match)
|
||||||
|
; XXX contract
|
||||||
(provide xexpr+extras->xexpr)
|
(provide xexpr+extras->xexpr)
|
||||||
|
|
||||||
(define xexpr+extras->xexpr
|
(define xexpr+extras->xexpr
|
||||||
|
|
|
@ -162,12 +162,17 @@ This function writes a @scheme[configuration-table] to @scheme[path].
|
||||||
@scheme[make-servlet-namespace] procedure needed by the @scheme[make] functions
|
@scheme[make-servlet-namespace] procedure needed by the @scheme[make] functions
|
||||||
of @filepath{dispatchers/dispatch-servlets.ss} and @filepath{dispatchers/dispatch-lang.ss}.
|
of @filepath{dispatchers/dispatch-servlets.ss} and @filepath{dispatchers/dispatch-lang.ss}.
|
||||||
|
|
||||||
@; XXX Define make-servlet-namespace?
|
@defthing[make-servlet-namespace/c contract?]{
|
||||||
@; XXX Use actual keyword argument syntax
|
Equivalent to
|
||||||
|
@schemeblock[
|
||||||
|
(->* ()
|
||||||
|
(#:additional-specs (listof module-path?))
|
||||||
|
namespace?)
|
||||||
|
].
|
||||||
|
}
|
||||||
|
|
||||||
@defproc[(make-make-servlet-namespace (#:to-be-copied-module-specs to-be-copied-module-specs (listof module-spec?)))
|
@defproc[(make-make-servlet-namespace (#:to-be-copied-module-specs to-be-copied-module-specs (listof module-path?)))
|
||||||
(key-> ([additional-specs (listof module-spec?)])
|
make-servlet-namespace/c]{
|
||||||
namespace?)]{
|
|
||||||
This function creates a function that when called will construct a new @scheme[namespace] that
|
This function creates a function that when called will construct a new @scheme[namespace] that
|
||||||
has all the modules from @scheme[to-be-copied-module-specs] and @scheme[additional-specs], as well
|
has all the modules from @scheme[to-be-copied-module-specs] and @scheme[additional-specs], as well
|
||||||
as @scheme[mzscheme] and @scheme[mred], provided they are already attached
|
as @scheme[mzscheme] and @scheme[mred], provided they are already attached
|
||||||
|
|
|
@ -38,12 +38,12 @@ documentation will be useful.
|
||||||
|
|
||||||
@filepath{dispatchers/dispatch.ss} provides a few functions for dispatchers in general.
|
@filepath{dispatchers/dispatch.ss} provides a few functions for dispatchers in general.
|
||||||
|
|
||||||
@defthing[dispatcher? contract?]{
|
@defthing[dispatcher/c contract?]{
|
||||||
Equivalent to @scheme[(connection? request? . -> . void)].
|
Equivalent to @scheme[(connection? request? . -> . void)].
|
||||||
}
|
}
|
||||||
|
|
||||||
@defproc[(dispatcher-interface-version? (any any/c)) boolean?]{
|
@defproc[(dispatcher-interface-version/c (any any/c)) boolean?]{
|
||||||
Returns @scheme[#t] if @scheme[any] is @scheme['v1]. Returns @scheme[#f] otherwise.
|
Equivalent to @scheme[(symbols 'v1)]
|
||||||
}
|
}
|
||||||
|
|
||||||
@defstruct[exn:dispatcher ()]{
|
@defstruct[exn:dispatcher ()]{
|
||||||
|
@ -55,7 +55,7 @@ documentation will be useful.
|
||||||
Raises a @scheme[exn:dispatcher]
|
Raises a @scheme[exn:dispatcher]
|
||||||
}
|
}
|
||||||
|
|
||||||
As the @scheme[dispatcher?] contract suggests, a dispatcher is a function that takes a connection
|
As the @scheme[dispatcher/c] contract suggests, a dispatcher is a function that takes a connection
|
||||||
and request object and does something to them. Mostly likely it will generate
|
and request object and does something to them. Mostly likely it will generate
|
||||||
some response and output it on the connection, but it may do something
|
some response and output it on the connection, but it may do something
|
||||||
different. For example, it may apply some test to the request object, perhaps
|
different. For example, it may apply some test to the request object, perhaps
|
||||||
|
@ -64,7 +64,7 @@ otherwise.
|
||||||
|
|
||||||
Consider the following example dispatcher, that captures the essence of URL rewriting:
|
Consider the following example dispatcher, that captures the essence of URL rewriting:
|
||||||
@schemeblock[
|
@schemeblock[
|
||||||
(code:comment "(url? -> url?) dispatcher? -> dispatcher?")
|
(code:comment "(url? -> url?) dispatcher/c -> dispatcher/c")
|
||||||
(lambda (rule inner)
|
(lambda (rule inner)
|
||||||
(lambda (conn req)
|
(lambda (conn req)
|
||||||
(code:comment "Call the inner dispatcher...")
|
(code:comment "Call the inner dispatcher...")
|
||||||
|
@ -84,14 +84,14 @@ Consider the following example dispatcher, that captures the essence of URL rewr
|
||||||
@filepath{dispatchers/filesystem-map.ss} provides a means of mapping
|
@filepath{dispatchers/filesystem-map.ss} provides a means of mapping
|
||||||
URLs to paths on the filesystem.
|
URLs to paths on the filesystem.
|
||||||
|
|
||||||
@defthing[url-path? contract?]{
|
@defthing[url-path/c contract?]{
|
||||||
This contract is equivalent to @scheme[((url?) . ->* . (path? (listof path-element?)))].
|
This contract is equivalent to @scheme[((url?) . ->* . (path? (listof path-element?)))].
|
||||||
The returned @scheme[path?] is the path on disk. The list is the list of
|
The returned @scheme[path?] is the path on disk. The list is the list of
|
||||||
path elements that correspond to the path of the URL.}
|
path elements that correspond to the path of the URL.}
|
||||||
|
|
||||||
@defproc[(make-url->path (base path?))
|
@defproc[(make-url->path (base path?))
|
||||||
url-path?]{
|
url-path/c]{
|
||||||
The @scheme[url-path?] returned by this procedure considers the root
|
The @scheme[url-path/c] returned by this procedure considers the root
|
||||||
URL to be @scheme[base]. It ensures that @scheme[".."]s in the URL
|
URL to be @scheme[base]. It ensures that @scheme[".."]s in the URL
|
||||||
do not escape the @scheme[base] and removes them silently otherwise.}
|
do not escape the @scheme[base] and removes them silently otherwise.}
|
||||||
|
|
||||||
|
@ -112,8 +112,8 @@ URLs to paths on the filesystem.
|
||||||
@elem{defines a dispatcher constructor
|
@elem{defines a dispatcher constructor
|
||||||
that invokes a sequence of dispatchers until one applies.}]{
|
that invokes a sequence of dispatchers until one applies.}]{
|
||||||
|
|
||||||
@defproc[(make (dispatcher dispatcher?) ...)
|
@defproc[(make (dispatcher dispatcher/c) ...)
|
||||||
dispatcher?]{
|
dispatcher/c]{
|
||||||
Invokes each @scheme[dispatcher], invoking the next if the first
|
Invokes each @scheme[dispatcher], invoking the next if the first
|
||||||
calls @scheme[next-dispatcher]. If no @scheme[dispatcher] applies,
|
calls @scheme[next-dispatcher]. If no @scheme[dispatcher] applies,
|
||||||
then it calls @scheme[next-dispatcher] itself.
|
then it calls @scheme[next-dispatcher] itself.
|
||||||
|
@ -128,7 +128,7 @@ URLs to paths on the filesystem.
|
||||||
dispatcher.}]{
|
dispatcher.}]{
|
||||||
|
|
||||||
@defproc[(make [new-timeout integer?])
|
@defproc[(make [new-timeout integer?])
|
||||||
dispatcher?]{
|
dispatcher/c]{
|
||||||
Changes the timeout on the connection with @scheme[adjust-connection-timeout!]
|
Changes the timeout on the connection with @scheme[adjust-connection-timeout!]
|
||||||
called with @scheme[new-timeout].
|
called with @scheme[new-timeout].
|
||||||
}}
|
}}
|
||||||
|
@ -139,7 +139,7 @@ URLs to paths on the filesystem.
|
||||||
@elem{defines a dispatcher constructor.}]{
|
@elem{defines a dispatcher constructor.}]{
|
||||||
|
|
||||||
@defproc[(make (proc (request? . -> . response?)))
|
@defproc[(make (proc (request? . -> . response?)))
|
||||||
dispatcher?]{
|
dispatcher/c]{
|
||||||
Constructs a dispatcher that calls @scheme[proc] on the request
|
Constructs a dispatcher that calls @scheme[proc] on the request
|
||||||
object, and outputs the response to the connection.
|
object, and outputs the response to the connection.
|
||||||
}}
|
}}
|
||||||
|
@ -152,8 +152,8 @@ URLs to paths on the filesystem.
|
||||||
that calls an underlying dispatcher
|
that calls an underlying dispatcher
|
||||||
with all requests that pass a predicate.}]{
|
with all requests that pass a predicate.}]{
|
||||||
|
|
||||||
@defproc[(make (regex regexp?) (inner dispatcher?))
|
@defproc[(make (regex regexp?) (inner dispatcher/c))
|
||||||
dispatcher?]{
|
dispatcher/c]{
|
||||||
Calls @scheme[inner] if the URL path of the request, converted to
|
Calls @scheme[inner] if the URL path of the request, converted to
|
||||||
a string, matches @scheme[regex]. Otherwise, calls @scheme[next-dispatcher].
|
a string, matches @scheme[regex]. Otherwise, calls @scheme[next-dispatcher].
|
||||||
}}
|
}}
|
||||||
|
@ -166,7 +166,7 @@ URLs to paths on the filesystem.
|
||||||
URL path.}]{
|
URL path.}]{
|
||||||
|
|
||||||
@defproc[(make (path string?) (proc (request? . -> . response?)))
|
@defproc[(make (path string?) (proc (request? . -> . response?)))
|
||||||
dispatcher?]{
|
dispatcher/c]{
|
||||||
Checks if the request URL path as a string is equal to @scheme[path]
|
Checks if the request URL path as a string is equal to @scheme[path]
|
||||||
and if so, calls @scheme[proc] for a response.
|
and if so, calls @scheme[proc] for a response.
|
||||||
}
|
}
|
||||||
|
@ -221,7 +221,7 @@ a URL that refreshes the password file, servlet cache, etc.}
|
||||||
|
|
||||||
@defproc[(make [#:format format format-req/c paren-format]
|
@defproc[(make [#:format format format-req/c paren-format]
|
||||||
[#:log-path log-path path-string? "log"])
|
[#:log-path log-path path-string? "log"])
|
||||||
dispatcher?]{
|
dispatcher/c]{
|
||||||
Logs requests to @scheme[log-path] by using @scheme[format] to format the requests.
|
Logs requests to @scheme[log-path] by using @scheme[format] to format the requests.
|
||||||
Then invokes @scheme[next-dispatcher].
|
Then invokes @scheme[next-dispatcher].
|
||||||
}}
|
}}
|
||||||
|
@ -238,7 +238,7 @@ a URL that refreshes the password file, servlet cache, etc.}
|
||||||
((url url?) (header header?) . -> . response?)
|
((url url?) (header header?) . -> . response?)
|
||||||
(gen-authentication-responder "forbidden.html")])
|
(gen-authentication-responder "forbidden.html")])
|
||||||
(values (-> void)
|
(values (-> void)
|
||||||
dispatcher?)]{
|
dispatcher/c)]{
|
||||||
The first returned value is a procedure that refreshes the password
|
The first returned value is a procedure that refreshes the password
|
||||||
file used by the dispatcher.
|
file used by the dispatcher.
|
||||||
|
|
||||||
|
@ -267,8 +267,8 @@ a URL that refreshes the password file, servlet cache, etc.}
|
||||||
@elem{defines a dispatcher constructor
|
@elem{defines a dispatcher constructor
|
||||||
that calls a different dispatcher based upon the host requested.}]{
|
that calls a different dispatcher based upon the host requested.}]{
|
||||||
|
|
||||||
@defproc[(make (lookup-dispatcher (symbol? . -> . dispatcher?)))
|
@defproc[(make (lookup-dispatcher (symbol? . -> . dispatcher/c)))
|
||||||
dispatcher?]{
|
dispatcher/c]{
|
||||||
Extracts a host from the URL requested, or the Host HTTP header,
|
Extracts a host from the URL requested, or the Host HTTP header,
|
||||||
calls @scheme[lookup-dispatcher] with the host, and invokes the
|
calls @scheme[lookup-dispatcher] with the host, and invokes the
|
||||||
returned dispatcher. If no host can be extracted, then @scheme['none]
|
returned dispatcher. If no host can be extracted, then @scheme['none]
|
||||||
|
@ -284,7 +284,7 @@ a URL that refreshes the password file, servlet cache, etc.}
|
||||||
@defproc[(make [#:url->path url->path url->path?]
|
@defproc[(make [#:url->path url->path url->path?]
|
||||||
[#:path->mime-type path->mime-type (path? . -> . bytes?) (lambda (path) TEXT/HTML-MIME-TYPE)]
|
[#:path->mime-type path->mime-type (path? . -> . bytes?) (lambda (path) TEXT/HTML-MIME-TYPE)]
|
||||||
[#:indices indices (listof string?) (list "index.html" "index.htm")])
|
[#:indices indices (listof string?) (list "index.html" "index.htm")])
|
||||||
dispatcher?]{
|
dispatcher/c]{
|
||||||
Uses @scheme[url->path] to extract a path from the URL in the request
|
Uses @scheme[url->path] to extract a path from the URL in the request
|
||||||
object. If this path does not exist, then the dispatcher does not apply and
|
object. If this path does not exist, then the dispatcher does not apply and
|
||||||
@scheme[next-dispatcher] is invoked.
|
@scheme[next-dispatcher] is invoked.
|
||||||
|
@ -322,7 +322,7 @@ a URL that refreshes the password file, servlet cache, etc.}
|
||||||
integer?
|
integer?
|
||||||
30])
|
30])
|
||||||
(values (-> void)
|
(values (-> void)
|
||||||
dispatcher?)]{
|
dispatcher/c)]{
|
||||||
The first returned value is a procedure that refreshes the servlet
|
The first returned value is a procedure that refreshes the servlet
|
||||||
code cache.
|
code cache.
|
||||||
|
|
||||||
|
@ -354,7 +354,7 @@ a URL that refreshes the password file, servlet cache, etc.}
|
||||||
[#:responders-servlet responders-servlet
|
[#:responders-servlet responders-servlet
|
||||||
((url url?) (exn exn?) . -> . response?)
|
((url url?) (exn exn?) . -> . response?)
|
||||||
servlet-error-responder])
|
servlet-error-responder])
|
||||||
dispatcher?]{
|
dispatcher/c]{
|
||||||
If the request URL contains a serialized continuation, then it is invoked with the
|
If the request URL contains a serialized continuation, then it is invoked with the
|
||||||
request. Otherwise, @scheme[url->path] is used to resolve the URL to a path.
|
request. Otherwise, @scheme[url->path] is used to resolve the URL to a path.
|
||||||
The path is evaluated as a module, in a namespace constructed by @scheme[make-servlet-namespace].
|
The path is evaluated as a module, in a namespace constructed by @scheme[make-servlet-namespace].
|
||||||
|
@ -376,6 +376,6 @@ a URL that refreshes the password file, servlet cache, etc.}
|
||||||
}
|
}
|
||||||
|
|
||||||
@defproc[(make)
|
@defproc[(make)
|
||||||
dispatcher?]{
|
dispatcher/c]{
|
||||||
Returns a dispatcher that prints memory usage on every request.
|
Returns a dispatcher that prints memory usage on every request.
|
||||||
}}
|
}}
|
||||||
|
|
|
@ -134,7 +134,7 @@ by the Web language API.
|
||||||
Note: The continuation is NOT stuffed.
|
Note: The continuation is NOT stuffed.
|
||||||
}
|
}
|
||||||
|
|
||||||
@defproc[(send/suspend/dispatch [make-response (embed/url? . -> . response?)])
|
@defproc[(send/suspend/dispatch [make-response (embed/url/c . -> . response?)])
|
||||||
any/c]{
|
any/c]{
|
||||||
Calls @scheme[make-response] with a function that, when called with a procedure from
|
Calls @scheme[make-response] with a function that, when called with a procedure from
|
||||||
@scheme[request?] to @scheme[any/c] will generate a URL, that when invoked will call
|
@scheme[request?] to @scheme[any/c] will generate a URL, that when invoked will call
|
||||||
|
|
|
@ -26,7 +26,7 @@ the users and implementers of managers.
|
||||||
@defstruct[manager ([create-instance ((-> void) . -> . number?)]
|
@defstruct[manager ([create-instance ((-> void) . -> . number?)]
|
||||||
[adjust-timeout! (number? number? . -> . void)]
|
[adjust-timeout! (number? number? . -> . void)]
|
||||||
[clear-continuations! (number? . -> . void)]
|
[clear-continuations! (number? . -> . void)]
|
||||||
[continuation-store! (number? any/c expiration-handler? . -> . (list/c number? number?))]
|
[continuation-store! (number? any/c expiration-handler/c . -> . (list/c number? number?))]
|
||||||
[continuation-lookup (number? number? number? . -> . any/c)])]{
|
[continuation-lookup (number? number? number? . -> . any/c)])]{
|
||||||
@scheme[create-instance] is called to initialize a instance, to hold the
|
@scheme[create-instance] is called to initialize a instance, to hold the
|
||||||
continuations of one servlet session. It is passed
|
continuations of one servlet session. It is passed
|
||||||
|
@ -49,13 +49,13 @@ the users and implementers of managers.
|
||||||
}
|
}
|
||||||
|
|
||||||
@defstruct[(exn:fail:servlet-manager:no-instance exn:fail)
|
@defstruct[(exn:fail:servlet-manager:no-instance exn:fail)
|
||||||
([expiration-handler expiration-handler?])]{
|
([expiration-handler expiration-handler/c])]{
|
||||||
This exception should be thrown by a manager when an instance is looked
|
This exception should be thrown by a manager when an instance is looked
|
||||||
up that does not exist.
|
up that does not exist.
|
||||||
}
|
}
|
||||||
|
|
||||||
@defstruct[(exn:fail:servlet-manager:no-continuation exn:fail)
|
@defstruct[(exn:fail:servlet-manager:no-continuation exn:fail)
|
||||||
([expiration-handler expiration-handler?])]{
|
([expiration-handler expiration-handler/c])]{
|
||||||
This exception should be thrown by a manager when a continuation is
|
This exception should be thrown by a manager when a continuation is
|
||||||
looked up that does not exist.
|
looked up that does not exist.
|
||||||
}
|
}
|
||||||
|
@ -68,7 +68,7 @@ the users and implementers of managers.
|
||||||
|
|
||||||
@filepath{managers/none.ss} defines a manager constructor:
|
@filepath{managers/none.ss} defines a manager constructor:
|
||||||
|
|
||||||
@defproc[(create-none-manager (instance-expiration-handler expiration-handler?))
|
@defproc[(create-none-manager (instance-expiration-handler expiration-handler/c))
|
||||||
manager?]{
|
manager?]{
|
||||||
This manager does not actually store any continuation or instance data.
|
This manager does not actually store any continuation or instance data.
|
||||||
You could use it if you know your servlet does not use the continuation
|
You could use it if you know your servlet does not use the continuation
|
||||||
|
@ -91,7 +91,7 @@ Web Language. (See @secref["lang"].)
|
||||||
|
|
||||||
@filepath{managers/timeouts.ss} defines a manager constructor:
|
@filepath{managers/timeouts.ss} defines a manager constructor:
|
||||||
|
|
||||||
@defproc[(create-timeout-manager [instance-exp-handler expiration-handler?]
|
@defproc[(create-timeout-manager [instance-exp-handler expiration-handler/c]
|
||||||
[instance-timeout number?]
|
[instance-timeout number?]
|
||||||
[continuation-timeout number?])
|
[continuation-timeout number?])
|
||||||
manager?]{
|
manager?]{
|
||||||
|
@ -122,7 +122,7 @@ deployments of the @web-server .
|
||||||
@filepath{managers/lru.ss} defines a manager constructor:
|
@filepath{managers/lru.ss} defines a manager constructor:
|
||||||
|
|
||||||
@defproc[(create-LRU-manager
|
@defproc[(create-LRU-manager
|
||||||
[instance-expiration-handler expiration-handler?]
|
[instance-expiration-handler expiration-handler/c]
|
||||||
[check-interval integer?]
|
[check-interval integer?]
|
||||||
[collect-interval integer?]
|
[collect-interval integer?]
|
||||||
[collect? (-> boolean?)]
|
[collect? (-> boolean?)]
|
||||||
|
@ -155,7 +155,7 @@ deployments of the @web-server .
|
||||||
The recommended usage of this manager is codified as the following function:
|
The recommended usage of this manager is codified as the following function:
|
||||||
|
|
||||||
@defproc[(make-threshold-LRU-manager
|
@defproc[(make-threshold-LRU-manager
|
||||||
[instance-expiration-handler expiration-handler?]
|
[instance-expiration-handler expiration-handler/c]
|
||||||
[memory-threshold number?])
|
[memory-threshold number?])
|
||||||
manager?]{
|
manager?]{
|
||||||
This creates an LRU manager with the following behavior:
|
This creates an LRU manager with the following behavior:
|
||||||
|
|
|
@ -15,7 +15,7 @@ The @web-server provides a way to quickly configure and start a server instance.
|
||||||
[#:listen-ip listen-ip string? "127.0.0.1"]
|
[#:listen-ip listen-ip string? "127.0.0.1"]
|
||||||
[#:port port number? 8000]
|
[#:port port number? 8000]
|
||||||
[#:manager manager manager? default-threshold-LRU-manager]
|
[#:manager manager manager? default-threshold-LRU-manager]
|
||||||
[#:servlet-namespace servlet-namespace (listof require-spec?) empty]
|
[#:servlet-namespace servlet-namespace (listof module-path?) empty]
|
||||||
[#:server-root-path server-root-path path? default-server-root-path]
|
[#:server-root-path server-root-path path? default-server-root-path]
|
||||||
[#:extra-files-path extra-files-path path? (build-path server-root-path "htdocs")]
|
[#:extra-files-path extra-files-path path? (build-path server-root-path "htdocs")]
|
||||||
[#:servlets-root servlets-root path? (build-path server-root-path ".")]
|
[#:servlets-root servlets-root path? (build-path server-root-path ".")]
|
||||||
|
|
|
@ -61,9 +61,9 @@ for use in servlets.
|
||||||
|
|
||||||
@defthing[url-transform? contract?]{Equivalent to @scheme[(k-url? . -> . k-url?)].}
|
@defthing[url-transform? contract?]{Equivalent to @scheme[(k-url? . -> . k-url?)].}
|
||||||
|
|
||||||
@defthing[expiration-handler? contract?]{Equivalent to @scheme[(or/c false/c (request? . -> . response?))].}
|
@defthing[expiration-handler/c contract?]{Equivalent to @scheme[(or/c false/c (request? . -> . response?))].}
|
||||||
|
|
||||||
@defthing[embed/url? contract?]{Equivalent to @scheme[(((request? . -> . any/c)) (expiration-handler?) . opt-> . string?)].}
|
@defthing[embed/url/c contract?]{Equivalent to @scheme[(((request? . -> . any/c)) (expiration-handler/c) . opt-> . string?)].}
|
||||||
|
|
||||||
@; ------------------------------------------------------------
|
@; ------------------------------------------------------------
|
||||||
@section[#:tag "request-structs.ss"]{HTTP Requests}
|
@section[#:tag "request-structs.ss"]{HTTP Requests}
|
||||||
|
@ -254,13 +254,13 @@ functions of interest for the servlet developer.}
|
||||||
Sends @scheme[response] to the client.
|
Sends @scheme[response] to the client.
|
||||||
}
|
}
|
||||||
|
|
||||||
@defthing[current-servlet-continuation-expiration-handler parameter?]{
|
@defthing[current-servlet-continuation-expiration-handler (parameter/c expiration-handler/c)]{
|
||||||
Holds the @scheme[expiration-handler?] to be used when a continuation
|
Holds the @scheme[expiration-handler/c] to be used when a continuation
|
||||||
captured in this context is expired, then looked up.
|
captured in this context is expired, then looked up.
|
||||||
}
|
}
|
||||||
|
|
||||||
@defproc[(send/suspend [make-response response-generator?]
|
@defproc[(send/suspend [make-response response-generator?]
|
||||||
[exp expiration-handler? (current-servlet-continuation-expiration-handler)])
|
[exp expiration-handler/c (current-servlet-continuation-expiration-handler)])
|
||||||
request?]{
|
request?]{
|
||||||
Captures the current continuation, stores it with @scheme[exp] as the expiration
|
Captures the current continuation, stores it with @scheme[exp] as the expiration
|
||||||
handler, and binds it to a URL. @scheme[make-response] is called with this URL and
|
handler, and binds it to a URL. @scheme[make-response] is called with this URL and
|
||||||
|
@ -287,7 +287,7 @@ functions of interest for the servlet developer.}
|
||||||
}
|
}
|
||||||
|
|
||||||
@defproc[(send/forward [make-response response-generator?]
|
@defproc[(send/forward [make-response response-generator?]
|
||||||
[exp expiration-handler? (current-servlet-continuation-expiration-handler)])
|
[exp expiration-handler/c (current-servlet-continuation-expiration-handler)])
|
||||||
request?]{
|
request?]{
|
||||||
Calls @scheme[clear-continuation-table!], then @scheme[send/suspend].
|
Calls @scheme[clear-continuation-table!], then @scheme[send/suspend].
|
||||||
}
|
}
|
||||||
|
@ -297,7 +297,7 @@ functions of interest for the servlet developer.}
|
||||||
Calls @scheme[clear-continuation-table!], then @scheme[send/back].
|
Calls @scheme[clear-continuation-table!], then @scheme[send/back].
|
||||||
}
|
}
|
||||||
|
|
||||||
@defproc[(send/suspend/dispatch [make-response (embed/url? . -> . response?)])
|
@defproc[(send/suspend/dispatch [make-response (embed/url/c . -> . response?)])
|
||||||
any/c]{
|
any/c]{
|
||||||
Calls @scheme[make-response] with a function that, when called with a procedure from
|
Calls @scheme[make-response] with a function that, when called with a procedure from
|
||||||
@scheme[request?] to @scheme[any/c] will generate a URL, that when invoked will call
|
@scheme[request?] to @scheme[any/c] will generate a URL, that when invoked will call
|
||||||
|
@ -323,7 +323,7 @@ functions of interest for the servlet developer.}
|
||||||
}
|
}
|
||||||
|
|
||||||
@; XXX Remove
|
@; XXX Remove
|
||||||
@defthing[current-url-transform parameter?]{
|
@defthing[current-url-transform (parameter/c url-transform?)]{
|
||||||
Holds a @scheme[url-transform?] function that is called by
|
Holds a @scheme[url-transform?] function that is called by
|
||||||
@scheme[send/suspend] to transform the URLs it generates.
|
@scheme[send/suspend] to transform the URLs it generates.
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,12 +2,16 @@
|
||||||
; Also derived from planet/untyped/instaservlet
|
; Also derived from planet/untyped/instaservlet
|
||||||
#lang scheme/base
|
#lang scheme/base
|
||||||
(require (prefix-in net: net/sendurl)
|
(require (prefix-in net: net/sendurl)
|
||||||
|
scheme/contract
|
||||||
scheme/list)
|
scheme/list)
|
||||||
(require web-server/web-server
|
(require web-server/web-server
|
||||||
web-server/managers/lru
|
web-server/managers/lru
|
||||||
|
web-server/managers/manager
|
||||||
web-server/private/servlet
|
web-server/private/servlet
|
||||||
web-server/configuration/namespace
|
web-server/configuration/namespace
|
||||||
web-server/private/cache-table
|
web-server/private/cache-table
|
||||||
|
web-server/private/request-structs
|
||||||
|
web-server/private/response-structs
|
||||||
web-server/private/util
|
web-server/private/util
|
||||||
web-server/configuration/responders
|
web-server/configuration/responders
|
||||||
web-server/dispatchers/dispatch
|
web-server/dispatchers/dispatch
|
||||||
|
@ -35,7 +39,22 @@
|
||||||
(div ([class "title"]) "Server Stopped")
|
(div ([class "title"]) "Server Stopped")
|
||||||
(p "Return to DrScheme.")))))))
|
(p "Return to DrScheme.")))))))
|
||||||
|
|
||||||
(provide serve/servlet)
|
(provide/contract
|
||||||
|
[serve/servlet (((request? . -> . response?))
|
||||||
|
(#:launch-browser? boolean?
|
||||||
|
#:quit? boolean?
|
||||||
|
#:listen-ip string?
|
||||||
|
#:port number?
|
||||||
|
#:manager manager?
|
||||||
|
#:servlet-namespace (listof module-path?)
|
||||||
|
#:server-root-path path?
|
||||||
|
#:extra-files-path path?
|
||||||
|
#:servlets-root path?
|
||||||
|
#:file-not-found-path path?
|
||||||
|
#:mime-types-path path?
|
||||||
|
#:servlet-path path?)
|
||||||
|
. ->* .
|
||||||
|
void)])
|
||||||
(define (serve/servlet new-servlet
|
(define (serve/servlet new-servlet
|
||||||
#:launch-browser?
|
#:launch-browser?
|
||||||
[launch-browser? #t]
|
[launch-browser? #t]
|
||||||
|
|
|
@ -32,6 +32,7 @@
|
||||||
(pre ,(exn->string exn)))))))])
|
(pre ,(exn->string exn)))))))])
|
||||||
(thunk)))
|
(thunk)))
|
||||||
|
|
||||||
|
; XXX contract
|
||||||
(provide
|
(provide
|
||||||
with-errors-to-browser)
|
with-errors-to-browser)
|
||||||
(provide/contract
|
(provide/contract
|
||||||
|
|
|
@ -1,27 +1,27 @@
|
||||||
#lang scheme/base
|
#lang scheme/base
|
||||||
(require mzlib/contract)
|
(require scheme/contract)
|
||||||
(require "../private/request-structs.ss"
|
(require "../private/request-structs.ss"
|
||||||
"../private/response-structs.ss")
|
"../private/response-structs.ss")
|
||||||
|
|
||||||
(define k-url?
|
(define k-url?
|
||||||
string?)
|
string?)
|
||||||
|
|
||||||
(define response-generator?
|
(define response-generator/c
|
||||||
(k-url? . -> . response?))
|
(k-url? . -> . response?))
|
||||||
|
|
||||||
(define url-transform?
|
(define url-transform/c
|
||||||
(k-url? . -> . k-url?))
|
(k-url? . -> . k-url?))
|
||||||
|
|
||||||
(define expiration-handler?
|
(define expiration-handler/c
|
||||||
(or/c false/c
|
(or/c false/c
|
||||||
(request? . -> . response?)))
|
(request? . -> . response?)))
|
||||||
|
|
||||||
(define embed/url?
|
(define embed/url/c
|
||||||
(((request? . -> . any/c)) (expiration-handler?) . opt-> . string?))
|
(((request? . -> . any/c)) (expiration-handler/c) . ->* . string?))
|
||||||
|
|
||||||
(provide/contract
|
(provide/contract
|
||||||
[response-generator? contract?]
|
[response-generator/c contract?]
|
||||||
[k-url? (any/c . -> . boolean?)]
|
[k-url? (any/c . -> . boolean?)]
|
||||||
[url-transform? contract?]
|
[url-transform/c contract?]
|
||||||
[expiration-handler? contract?]
|
[expiration-handler/c contract?]
|
||||||
[embed/url? contract?])
|
[embed/url/c contract?])
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
(require net/url
|
(require net/url
|
||||||
mzlib/list
|
mzlib/list
|
||||||
mzlib/plt-match
|
mzlib/plt-match
|
||||||
mzlib/contract
|
scheme/contract
|
||||||
mzlib/etc)
|
mzlib/etc)
|
||||||
(require "../managers/manager.ss"
|
(require "../managers/manager.ss"
|
||||||
"../private/util.ss"
|
"../private/util.ss"
|
||||||
|
@ -67,17 +67,17 @@
|
||||||
in-url)))
|
in-url)))
|
||||||
|
|
||||||
(provide/contract
|
(provide/contract
|
||||||
[current-url-transform parameter?]
|
[current-url-transform (parameter/c url-transform/c)]
|
||||||
[current-servlet-continuation-expiration-handler parameter?]
|
[current-servlet-continuation-expiration-handler (parameter/c expiration-handler/c)]
|
||||||
[redirect/get (-> request?)]
|
[redirect/get (-> request?)]
|
||||||
[redirect/get/forget (-> request?)]
|
[redirect/get/forget (-> request?)]
|
||||||
[adjust-timeout! (number? . -> . void?)]
|
[adjust-timeout! (number? . -> . void?)]
|
||||||
[clear-continuation-table! (-> void?)]
|
[clear-continuation-table! (-> void?)]
|
||||||
[send/back (response? . -> . void?)]
|
[send/back (response? . -> . void?)]
|
||||||
[send/finish (response? . -> . void?)]
|
[send/finish (response? . -> . void?)]
|
||||||
[send/suspend ((response-generator?) (expiration-handler?) . opt-> . request?)]
|
[send/suspend ((response-generator/c) (expiration-handler/c) . ->* . request?)]
|
||||||
[send/forward ((response-generator?) (expiration-handler?) . opt-> . request?)]
|
[send/forward ((response-generator/c) (expiration-handler/c) . ->* . request?)]
|
||||||
[send/suspend/dispatch ((embed/url? . -> . response?) . -> . any/c)])
|
[send/suspend/dispatch ((embed/url/c . -> . response?) . -> . any/c)])
|
||||||
|
|
||||||
;; ************************************************************
|
;; ************************************************************
|
||||||
;; EXPORTS
|
;; EXPORTS
|
||||||
|
|
|
@ -14,14 +14,14 @@
|
||||||
(->* (path-string?)
|
(->* (path-string?)
|
||||||
(#:port (or/c false/c number?)
|
(#:port (or/c false/c number?)
|
||||||
#:listen-ip (or/c false/c string?)
|
#:listen-ip (or/c false/c string?)
|
||||||
#:make-servlet-namespace make-servlet-namespace?)
|
#:make-servlet-namespace make-servlet-namespace/c)
|
||||||
unit?)]
|
unit?)]
|
||||||
[configuration-table-sexpr->web-config@
|
[configuration-table-sexpr->web-config@
|
||||||
(->* (list?) ; XXX
|
(->* (list?) ; XXX
|
||||||
(#:web-server-root path-string?
|
(#:web-server-root path-string?
|
||||||
#:port (or/c false/c number?)
|
#:port (or/c false/c number?)
|
||||||
#:listen-ip (or/c false/c string?)
|
#:listen-ip (or/c false/c string?)
|
||||||
#:make-servlet-namespace make-servlet-namespace?)
|
#:make-servlet-namespace make-servlet-namespace/c)
|
||||||
unit?)])
|
unit?)])
|
||||||
|
|
||||||
; configuration-table->web-config@ : path -> configuration
|
; configuration-table->web-config@ : path -> configuration
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
(prefix-in http: "private/request.ss"))
|
(prefix-in http: "private/request.ss"))
|
||||||
(provide/contract
|
(provide/contract
|
||||||
[serve
|
[serve
|
||||||
(->* (#:dispatch dispatcher?)
|
(->* (#:dispatch dispatcher/c)
|
||||||
(#:tcp@ unit?
|
(#:tcp@ unit?
|
||||||
#:port number?
|
#:port number?
|
||||||
#:listen-ip (or/c false/c string?)
|
#:listen-ip (or/c false/c string?)
|
||||||
|
@ -21,7 +21,7 @@
|
||||||
#:initial-connection-timeout number?)
|
#:initial-connection-timeout number?)
|
||||||
(-> void))]
|
(-> void))]
|
||||||
[serve/ports
|
[serve/ports
|
||||||
(->* (#:dispatch dispatcher?)
|
(->* (#:dispatch dispatcher/c)
|
||||||
(#:tcp@ unit?
|
(#:tcp@ unit?
|
||||||
#:ports (listof number?)
|
#:ports (listof number?)
|
||||||
#:listen-ip (or/c false/c string?)
|
#:listen-ip (or/c false/c string?)
|
||||||
|
@ -29,7 +29,7 @@
|
||||||
#:initial-connection-timeout number?)
|
#:initial-connection-timeout number?)
|
||||||
(-> void))]
|
(-> void))]
|
||||||
[serve/ips+ports
|
[serve/ips+ports
|
||||||
(->* (#:dispatch dispatcher?)
|
(->* (#:dispatch dispatcher/c)
|
||||||
(#:tcp@ unit?
|
(#:tcp@ unit?
|
||||||
#:ips+ports (listof (cons/c (or/c false/c string?) (listof number?)))
|
#:ips+ports (listof (cons/c (or/c false/c string?) (listof number?)))
|
||||||
#:max-waiting number?
|
#:max-waiting number?
|
||||||
|
|
Loading…
Reference in New Issue
Block a user