► |  | Web Server: PLT HTTP Server

1 | Running the Web Server
2 | Writing Servlets
3 | Extending the Web Server
4 | Troubleshooting and Tips
5 | Acknowledgements
| Index

▼ | 2 | Writing Servlets

2.1 | Defining a Servlet
2.2 | APIs
2.3 | Common Contracts
2.4 | HTTP
2.5 | Web Interaction
2.6 | Stateless Web Interaction
2.7 | Web Cells
2.8 | File Boxes
2.9 | Stateless Web Parameters
2.10 | Formlets
2.11 | Templates
2.12 | Continuation Managers

► | 2.6 | Stateless Web Interaction

2.6.1 | Low Level
2.6.2 | High Level
2.6.3 | Stuff URL

On this page:

2.6.1`` Low Level
send/ suspend
2.6.2`` High Level
send/ suspend/ url
send/ suspend/ hidden
send/ suspend/ dispatch
redirect/ get
2.6.3`` Stuff URL
stuff-url
stuffed-url?
unstuff-url

Version: 4.1.4
top← prev up next →

#### 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.

(redirect/get) → request?

See web-server/servlet/web.

##### 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.)

top← prev up next →