From 2ceb6f181f3a6d3d5694e4b7b5ba9022f5426665 Mon Sep 17 00:00:00 2001 From: Jay McCarthy Date: Tue, 29 May 2007 16:25:14 +0000 Subject: [PATCH] Rearranging svn: r6373 --- .../prototype-web-server/private/stuff-url.ss | 47 ++----------------- .../prototype-web-server/private/utils.ss | 26 +++++++--- 2 files changed, 23 insertions(+), 50 deletions(-) diff --git a/collects/web-server/prototype-web-server/private/stuff-url.ss b/collects/web-server/prototype-web-server/private/stuff-url.ss index 6ac47c712b..306d8490ba 100644 --- a/collects/web-server/prototype-web-server/private/stuff-url.ss +++ b/collects/web-server/prototype-web-server/private/stuff-url.ss @@ -4,44 +4,12 @@ (lib "plt-match.ss") "utils.ss") + ; XXX even though we allow all values to be serialized, we only protect against source modification of the servlet program. + ; XXX url: first try continuation, then turn into hash ; XXX different ways to hash, different ways to store (maybe cookie?) - ;; before reading this, familiarize yourself with serializable values - ;; covered in ch 36 in the MzScheme manual. - - ;; To keep things small, only serialize closure structures. Furthermore, - ;; any such structures must come from the current servlet. One exception is - ;; the kont structure. - - ;; The structure-type list (module map) will be replaced by a list of numbers. For example, - ;; if the third element of the list is 19, then the third structure type is - ;; the same as the 19th closure type defined in the servlet module. - - ;; The list described above may also contain the symbol 'k, if kont is *not* - ;; at position 0 in the original module map. - - ;; The labeling code is the symbol prefix that is created by labels.ss. If the - ;; servlet is changed in some non-trivial way (i.e. not whitespace or comment), - ;; then a new labeling code will be created for the servlet. Thus the labeling code - ;; must be kept as part of the URL. URLs with old labeling codes will simply not - ;; work since the refactored module will not export any identifiers based off the - ;; old labeling. - - ;; **************************************** - ;; FUTURE DESIGN - - ;; To eliminate the single module requirement, create a global module map at compile time. - ;; The global map must handle all struct types from any required modules. Then re-write - ;; the serialized value (+ any graph and fixups) substituting the global numbers for the - ;; local numbers. - - ;; Once the local value (+ any graph and fixups) have been translated to use the global map - ;; then the local map can be eliminated. The labeling code must still be preserved in the - ;; URL. Now the labeling code should identify the global map. Hmm... in this model the labeling - ;; code should somehow reflect any changes to the global map. - ;; **************************************** ;; URL LAYOUT @@ -65,14 +33,7 @@ extend-url-query unstuff-url find-binding) - - (define (read/string str) - (read (open-input-string str))) - (define (write/string v) - (define str (open-output-string)) - (write v str) - (get-output-string str)) - + ;; compress-mod-map : (listof (cons mod-spec symbol)) -> (listof (cons (or mod-spec number) symbol)) (define (compress-mod-map mm) (compress-mod-map/seen empty mm)) @@ -311,4 +272,4 @@ [(null? qry) #f] [(eqv? key (caar qry)) (read (open-input-string (cdar qry)))] - [else (find-binding key (cdr qry))]))) + [else (find-binding key (cdr qry))]))) \ No newline at end of file diff --git a/collects/web-server/prototype-web-server/private/utils.ss b/collects/web-server/prototype-web-server/private/utils.ss index e03775f35b..a57c5cbbca 100644 --- a/collects/web-server/prototype-web-server/private/utils.ss +++ b/collects/web-server/prototype-web-server/private/utils.ss @@ -1,10 +1,23 @@ (module utils mzscheme - (require (lib "url.ss" "net") + (require (lib "contract.ss") + (lib "url.ss" "net") (lib "plt-match.ss") - (lib "list.ss")) - (provide url->servlet-path - make-session-url - split-url-path) + (lib "list.ss") + (lib "serialize.ss")) + + (provide/contract + [read/string (string? . -> . serializable?)] + [write/string (serializable? . -> . string?)] + [url->servlet-path (url? . -> . (listof string?))] + [make-session-url (url? (listof string?) . -> . url?)] + [split-url-path (url? url? . -> . (or/c (listof string?) false/c))]) + + (define (read/string str) + (read (open-input-string str))) + (define (write/string v) + (define str (open-output-string)) + (write v str) + (get-output-string str)) ;; make-session-url: url (listof string) -> url ;; produce a new url for this session: @@ -109,5 +122,4 @@ [(string=? (car pref-path) (car suff-path)) (loop (cdr pref-path) (cdr suff-path))] [else - (error "split-url-path: first path is not a preffix of the second")]))) - ) + (error "split-url-path: first path is not a preffix of the second")])))) \ No newline at end of file