diff --git a/collects/web-server/scribblings/configuration.scrbl b/collects/web-server/scribblings/configuration.scrbl index ea9dd0356d..ce9b731b20 100644 --- a/collects/web-server/scribblings/configuration.scrbl +++ b/collects/web-server/scribblings/configuration.scrbl @@ -11,7 +11,10 @@ configuring the @web-server . @; ------------------------------------------------------------ @section[#:tag "configuration-table-structs.ss"]{Configuration Table Structure} -@(require (for-label web-server/configuration/configuration-table-structs)) +@(require (for-label web-server/configuration/configuration-table-structs + web-server/http + net/url + web-server/private/util)) @defmodule[web-server/configuration/configuration-table-structs]{ diff --git a/collects/web-server/scribblings/dispatchers.scrbl b/collects/web-server/scribblings/dispatchers.scrbl index 0d07bf4c98..1f7ffe3c0d 100644 --- a/collects/web-server/scribblings/dispatchers.scrbl +++ b/collects/web-server/scribblings/dispatchers.scrbl @@ -1,5 +1,13 @@ #lang scribble/doc @(require "web-server.ss" + (for-label web-server/http + net/url + web-server/servlet/setup + web-server/configuration/responders + web-server/private/servlet + scheme/date + web-server/private/util + web-server/private/connection-manager) (for-syntax scheme/base)) @(define-syntax (a-dispatcher stx) @@ -70,7 +78,7 @@ Consider the following example dispatcher, that captures the essence of URL rewr (code:comment "Call the inner dispatcher...") (inner conn (code:comment "with a new request object...") - (copy-struct request req + (struct-copy request req (code:comment "with a new URL!") [request-uri (rule (request-uri req))])))) ] @@ -109,7 +117,7 @@ URLs to paths on the filesystem. by a file. The most prominent example is obviously servlets.} @defproc[(filter-url->path [regex regexp?] - [url->path url-path/c]) + [url->path url->path/c]) url->path/c]{ Runs the underlying @scheme[url->path] but will only return if the path, when considered as a string, matches the @scheme[regex]. This is useful to disallow strange files, like GIFs, from being considered @@ -286,7 +294,7 @@ a URL that refreshes the password file, servlet cache, etc.} @scheme[password-file] is parsed as: @schemeblock[(list ([domain : string?] - [path : string-regexp?] + [path : string?] (code:comment "This string is interpreted as a regex") (list [user : symbol?] [pass : string?]) ...) @@ -351,11 +359,11 @@ a URL that refreshes the password file, servlet cache, etc.} @defproc[(make [url->servlet url->servlet/c] [#:responders-servlet-loading responders-servlet-loading - ((url url?) (exn exn?) . -> . response?) + (url? exn? . -> . response?) servlet-loading-responder] [#:responders-servlet responders-servlet - ((url url?) (exn exn?) . -> . response?) + (url? exn? . -> . response?) servlet-error-responder]) dispatcher/c]{ This dispatcher runs Scheme servlets, using @scheme[url->servlet] to resolve URLs to the underlying servlets. diff --git a/collects/web-server/scribblings/private.scrbl b/collects/web-server/scribblings/private.scrbl index 80b1b5e166..7e84ba30a8 100644 --- a/collects/web-server/scribblings/private.scrbl +++ b/collects/web-server/scribblings/private.scrbl @@ -2,6 +2,12 @@ @(require "web-server.ss") @title[#:tag "private" #:style 'toc]{Internal} +@(require (for-label scheme/tcp + web-server/dispatchers/dispatch + net/url + scheme/serialize + xml + net/tcp-sig)) The @web-server is a complicated piece of software and as a result, defines a number of interesting and independently useful sub-components. @@ -147,12 +153,15 @@ The @scheme[dispatch-server^] signature is an alias for @defthing[initial-connection-timeout integer?]{Specifies the initial timeout given to a connection.} @defproc[(read-request [c connection?] [p port?] - [port-addresses port-addresses?]) + [port-addresses (-> port? boolean? + (or/c (values string? string?) + (values string? (integer-in 1 65535) + string? (integer-in 1 65535))))]) any/c]{ Defines the way the server reads requests off connections to be passed to @scheme[dispatch]. } - @defthing[dispatch dispatcher?]{How to handle requests.} + @defthing[dispatch dispatcher/c]{How to handle requests.} } } diff --git a/collects/web-server/scribblings/servlet-setup.scrbl b/collects/web-server/scribblings/servlet-setup.scrbl index c10f91b277..c227d33150 100644 --- a/collects/web-server/scribblings/servlet-setup.scrbl +++ b/collects/web-server/scribblings/servlet-setup.scrbl @@ -2,7 +2,11 @@ @(require "web-server.ss") @title[#:tag "setup.ss"]{Setting Up Servlets} -@(require (for-label web-server/servlet/setup)) +@(require (for-label web-server/servlet/setup + web-server/http + web-server/private/servlet + web-server/managers/manager + web-server/configuration/namespace)) @defmodule[web-server/servlet/setup]{ @@ -39,7 +43,7 @@ Equivalent to @scheme[(path? . -> . servlet?)]. @defproc[(make-default-path->servlet [#:make-servlet-namespace make-servlet-namespace - make-servlet-namespace? + make-servlet-namespace/c (make-make-servlet-namespace)] [#:timeouts-default-servlet timeouts-default-servlet @@ -50,4 +54,24 @@ Equivalent to @scheme[(path? . -> . servlet?)]. using a timeout manager with @scheme[timeouts-default-servlet] as the default timeout (if no manager is given.) } -} \ No newline at end of file +} + +@section{Internal Servlet Representation} + +@defmodule[web-server/private/servlet]{ + @defstruct[servlet ([custodian custodian?] + [namespace namespace?] + [manager manager?] + [directory path?] + [handler (request? . -> . response?)]) + #:mutable]{ + Instances of this structure hold the necessary parts of a servlet: + the @scheme[custodian] responsible for the servlet's resources, + the @scheme[namespace] the servlet is executed within, + the @scheme[manager] responsible for the servlet's continuations, + the current @scheme[directory] of the servlet, + and the @scheme[handler] for all requests to the servlet. + } +} + + diff --git a/collects/web-server/scribblings/web-config-unit.scrbl b/collects/web-server/scribblings/web-config-unit.scrbl index 875a12f702..4aa33691df 100644 --- a/collects/web-server/scribblings/web-config-unit.scrbl +++ b/collects/web-server/scribblings/web-config-unit.scrbl @@ -3,8 +3,15 @@ @title[#:tag "web-config-unit.ss" #:style 'toc]{Web Config Unit} -@(require (for-label web-server/web-config-unit) - (for-label web-server/web-config-sig)) +@(require (for-label web-server/web-config-unit + web-server/configuration/namespace + web-server/configuration/configuration-table + web-server/configuration/configuration-table-structs + web-server/private/util + web-server/servlet/setup + scheme/tcp + (prefix-in servlets: web-server/dispatchers/dispatch-servlets) + web-server/web-config-sig)) The @web-server offers a unit-based approach to configuring the server. @@ -40,8 +47,8 @@ Provides contains the following identifiers. Passed to @scheme[tcp-accept]. } -@defthing[make-servlet-namespace make-servlet-namespace?]{ - Passed to @scheme[servlets:make]. +@defthing[make-servlet-namespace make-servlet-namespace/c]{ + Passed to @scheme[servlets:make] through @scheme[make-default-path->servlet]. } } @@ -54,7 +61,7 @@ Provides contains the following identifiers. @defproc[(configuration-table->web-config@ [path path?] [#:port port (or/c false/c port-number?) #f] [#:listen-ip listen-ip (or/c false/c string?) #f] - [#:make-servlet-namespace make-servlet-namespace make-servlet-namespace? (make-make-servlet-namespace)]) + [#:make-servlet-namespace make-servlet-namespace make-servlet-namespace/c (make-make-servlet-namespace)]) (unit? web-config^)]{ Reads the S-expression at @scheme[path] and calls @scheme[configuration-table-sexpr->web-config@] appropriately. @@ -64,7 +71,7 @@ Provides contains the following identifiers. [#:web-server-root web-server-root path? (directory-part default-configuration-table-path)] [#:port port (or/c false/c port-number?) #f] [#:listen-ip listen-ip (or/c false/c string?) #f] - [#:make-servlet-namespace make-servlet-namespace make-servlet-namespace? (make-make-servlet-namespace)]) + [#:make-servlet-namespace make-servlet-namespace make-servlet-namespace/c (make-make-servlet-namespace)]) (unit? web-config^)]{ Parses @scheme[sexpr] as a configuration-table and constructs a @scheme[web-config^] unit. } diff --git a/collects/web-server/scribblings/web-server-unit.scrbl b/collects/web-server/scribblings/web-server-unit.scrbl index 88094ea6c1..eddcff7bdd 100644 --- a/collects/web-server/scribblings/web-server-unit.scrbl +++ b/collects/web-server/scribblings/web-server-unit.scrbl @@ -3,8 +3,12 @@ @title[#:tag "web-server-unit.ss" #:style 'toc]{Web Server Unit} -@(require (for-label web-server/web-server-sig) - (for-label web-server/web-server-unit)) +@(require (for-label web-server/web-server-sig + web-server/web-server-unit + net/tcp-sig + web-server/dispatchers/dispatch + web-server/web-config-sig + web-server/web-config-unit)) The @web-server offers a unit-based approach to running the server. @@ -37,7 +41,7 @@ The @web-server offers a unit-based approach to running the server. @defthing[web-server@ (unit/c (web-config^ tcp^) (web-server^))]{ -Uses the @scheme[web-config^] to construct a @scheme[dispatcher?] +Uses the @scheme[web-config^] to construct a @scheme[dispatcher/c] function that sets up one virtual host dispatcher, for each virtual host in the @scheme[web-config^], that sequences the following operations: @@ -52,7 +56,7 @@ operations: @item{Serves files under the @scheme["/"] URL in the given htdocs directory.} ] -Using this @scheme[dispatcher?], it loads a dispatching server that provides @scheme[serve] +Using this @scheme[dispatcher/c], it loads a dispatching server that provides @scheme[serve] and @scheme[serve-ports] functions that operate as expected. }