2.4 Request Bindings
"servlet/bindings.ss" provides a number of helper functions for accessing request bindings.
(request-bindings req) | ||||||
| ||||||
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? |
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? |
Returns a list of all the bindings of id in the a-list binds.
(exists-binding? id binds) → boolean? |
id : symbol? |
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.