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