Artifact Content

Artifact 623bf6fbe534da1e68ba035d94fa0d95104a9275:

Wiki page [Interpreting Parameters] by murphy 2013-05-30 16:56:37.
D 2013-05-30T16:56:37.852
L Interpreting\sParameters
P 8d62edca81ef9c953dacd74943d3e4c831472aa6
U murphy
W 1310
<h1>Interpreting Parameters</h1>

WebGate represents request parameters as a hash table with string keys and passes them to the resource handler as its last argument. However, some requests contain complex parameters with type and header information and any request parameter can occur multiple times with different values, hence WebGate doesn't use simple strings as values in the parameters table but rather lists of instances of the <tt>message</tt> structure that has a SRFI-99 definition similar to this one:

  (define-record-type message
    #f #t
    type headers

The <tt>type</tt> field holds the content type of the message, <tt>headers</tt> contains an association list of headers and <tt>body</tt> contains the actual payload data as a string.

To access textual data conveniently, there is a synthetic accessor <tt>message-text</tt> that returns the message body iff it has a <tt>text/plain</tt> content type.

The helpers <tt>parameter-list-ref</tt> and <tt>parameter-ref</tt> allow you to extract a list of parameter values or a single value from a hash table. They take the hash table, a string key and an optional converter from message records to the desired target type as arguments. The message converter defaults to <tt>message-text</tt>.

Z e58262e6cc8972ee351d4dde3733459a