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