1 Running the Web Server
2 Scheme Servlets
3 Web Language Servlets
4 Configuration
5 Dispatchers
6 Web Config Unit
7 Web Server Unit
8 Continuation Managers
9 Internal
10 Troubleshooting
11 Acknowledgements
Index
On this page:
request-bindings
request-headers
extract-binding/ single
extract-bindings
exists-binding?
Version: 4.0.2

 

2.4 Request Bindings

 (require web-server/servlet/bindings)

"servlet/bindings.ss" provides a number of helper functions for accessing request bindings.

(request-bindings req)

 

 

(listof (or/c (cons/c symbol? string?)

              (cons/c symbol? bytes?)))

  req : request?

Translates the request-bindings/raw of req by interpreting bytes? as string?s, except in the case of binding:file bindings, which are left as is. Ids are then translated into lowercase symbols.

(request-headers req)  (listof (cons/c symbol? string?))

  req : request?

Translates the request-headers/raw of req by interpreting bytes? as string?s. Ids are then translated into lowercase symbols.

(extract-binding/single id binds)  string?

  id : symbol?

  binds : (listof (cons/c symbol? string?))

Returns the single binding associated with id in the a-list binds if there is exactly one binding. Otherwise raises exn:fail.

(extract-bindings id binds)  (listof string?)

  id : symbol?

  binds : (listof (cons/c symbol? string?))

Returns a list of all the bindings of id in the a-list binds.

(exists-binding? id binds)  boolean?

  id : symbol?

  binds : (listof (cons/c symbol? string))

Returns #t if binds contains a binding for id. Otherwise, #f.

These functions, while convenient, could introduce subtle bugs into your application. Examples: that they are case-insensitive could introduce a bug; if the data submitted is not in UTF-8 format, then the conversion to a string will fail; if an attacked submits a form field as if it were a file, when it is not, then the request-bindings will hold a bytes? object and your program will error; and, for file uploads you lose the filename.