WebStack

docs/parameters-headers.html

394:91ead0a6d5ec
2005-07-16 paulb [project @ 2005-07-16 14:39:32 by paulb] Fixed CGI newlines at end of headers.
     1 <?xml version="1.0" encoding="iso-8859-1"?>     2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"     3        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">     4 <html xmlns="http://www.w3.org/1999/xhtml">     5 <head>     6   <title>Request Header Parameters</title>     7   <meta name="generator" content="amaya 8.1a, see http://www.w3.org/Amaya/" />     8   <link href="styles.css" rel="stylesheet" type="text/css" />     9 </head>    10     11 <body>    12 <h2>Request Header Parameters</h2>    13     14 <p>Header parameters are typically specified in the URL like this:</p>    15 <pre>http://www.boddie.org.uk/application?param1=value1&amp;param2=value2</pre>    16     17 <p>Following the rules set out in <a href="paths.html">"URLs and Paths"</a>,    18 we can say that the "query string" employed is this:</p>    19 <pre>param1=value1&amp;param2=value2</pre>    20     21 <p>From this string, we may extract the parameters and state that they are    22 the following:</p>    23 <ul>    24   <li><code>param1</code> with the value <code>value1</code></li>    25   <li><code>param2</code> with the value <code>value2</code></li>    26 </ul>    27     28 <p>Parameters encoded in this way can be written into hyperlinks and may be    29 used to remember things as users navigate their way around an application.    30 Alternatively, a Web form (in HTML) written to use the <code>GET</code> <a    31 href="methods.html">request method</a> may be used to achieve the same    32 effect:</p>    33 <pre>&lt;form method="GET" action="http://www.boddie.org.uk/application"&gt;    34     &lt;input name="param1" type="text" /&gt;    35     &lt;input name="param2" type="text" /&gt;    36 &lt;/form&gt;</pre>    37     38 <div class="WebStack">    39 <h3>WebStack API - Accessing Header Parameters</h3>    40     41 <p>Transaction objects provide the following methods to access parameters    42 specified in request headers. The terminology used in the API describes such    43 parameters as path fields, since such parameters are often provided by form    44 fields.</p>    45 <dl>    46   <dt><code>get_fields_from_path</code></dt>    47     <dd>This returns the request parameters (fields) from the request headers    48       (as defined in the path or URL). The fields are provided in a    49       dictionary mapping field names to lists of values</dd>    50   <dt><code>get_query_string</code></dt>    51     <dd>This returns the query string - ie. the part of the path or URL which    52       contains the parameters. Typically, it is easier to use the above    53       method instead.</dd>    54 </dl>    55 </div>    56     57 <p>There are some limitations with header parameters:</p>    58 <ul>    59   <li>Since URLs are used to carry such parameters, any such parameter which    60     should remain hidden will appear in the URL and probably be shown in    61     browsers and other user interfaces.</li>    62   <li>There isn't widespread agreement about how non-ASCII characters should    63     be encoded in URLs. Therefore, care must be taken to encode and decode    64     values transferred in request headers.</li>    65 </ul>    66 </body>    67 </html>