2.6 Stateless Web Interaction
2.6.1 Low Level
(require web-server/lang/abort-resume) |
(send/suspend response-generator) → any |
response-generator : (continuation? . -> . any) |
Captures the current continuation in a serializable way and calls response-generator with it, returning the result.
2.6.2 High Level
(require web-server/lang/web) |
(send/suspend/url response-generator) → request? |
response-generator : (url? . -> . response?) |
Captures the current continuation. Serializes it and stuffs it into a URL. Calls response-generator with this URL and delivers the response to the client. If the URL is invoked the request is returned to this continuation.
(send/suspend/hidden response-generator) → request? |
response-generator : (url? xexpr? . -> . response?) |
Captures the current continuation. Serializes it and generates an INPUT form that includes the serialization as a hidden form. Calls response-generator with this URL and form field and delivers the response to the client. If the URL is invoked with form data containing the hidden form, the request is returned to this continuation.
Note: The continuation is NOT stuffed.
(send/suspend/dispatch make-response) → any/c |
make-response : (embed/url/c . -> . response?) |
Calls make-response with a function that, when called with a procedure from request? to any/c will generate a URL, that when invoked will call the function with the request? object and return the result to the caller of send/suspend/dispatch.
|
2.6.3 Stuff URL
(require web-server/lang/stuff-url) |
"lang/stuff-url.ss" provides an interface for "stuffing" serializable values into URLs. Currently there is a particular hard-coded behavior, but we hope to make it more flexible in the future.
(stuff-url v u) → url? |
v : serializable? |
u : url? |
Returns a URL based on u with v serialized and "stuffed" into it. The following steps are applied until the URL is short enough to be accepted by IE.
Put the plain-text serialization in the URL.
Compress the serialization with file/gzip into the URL.
Compute the MD5 of the compressed seralization and write it to "$HOME/.urls/M" where `M’ is the MD5. `M’ is then placed in the URL
(stuffed-url? u) → boolean? |
u : url? |
Checks if u appears to be produced by stuff-url.
(unstuff-url u) → serializable? |
u : url? |
Extracts the value previously serialized into u by stuff-url.
In the future, we will offer the facilities to:
Optionally use the content-addressed storage.
Use different hashing algorithms for the CAS.
Encrypt the serialized value.
Only use the CAS if the URL would be too long. (URLs may only be 1024 characters.)