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 Parameters and Uploads</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 <h1>Request Parameters and Uploads</h1> 13 14 <p>Even though it is possible to expose different parts of an application 15 using different <a href="paths.html">URLs and paths</a>, this usually is only 16 enough for applications which model some kind of <a 17 href="paths-filesystem.html">filesystem</a> or repository. Applications which 18 involve user input through forms, for example, need to be able to receive 19 such input by other means, and this is where request parameters come in. For 20 example, when a user fills out a form in a Web browser, the following 21 happens:</p> 22 <ol> 23 <li>The browser collects the values in the form fields and puts them in a 24 request as request parameters.</li> 25 <li>The request is sent to the server environment and into the 26 application.</li> 27 <li>The application reads the field values using the WebStack API.</li> 28 </ol> 29 30 <h2>Parameter Origins</h2> 31 32 <p>Request parameters can originate from two sources:</p> 33 <ul> 34 <li><a href="parameters-headers.html">Request headers</a> - parameters are 35 found here when they are specified in the URL as a "query string".</li> 36 <li><a href="parameters-body.html">Request bodies</a> - parameters are 37 found here when the POST <a href="methods.html">request method</a> is 38 used.</li> 39 </ul> 40 41 <div class="WebStack"> 42 <h3>WebStack API - Getting All Parameters</h3> 43 44 <p>If the origin of the different parameters received in a request is not 45 particularly interesting or important, WebStack provides a convenience method 46 in transaction objects to get all known parameters from a request:</p> 47 <dl> 48 <dt><code>get_fields</code></dt> 49 <dd>This method returns a dictionary mapping field names to lists of 50 values for all known parameters. Each value will be a Unicode 51 object.<br /> 52 An optional <code>encoding</code> parameter may be used to assist the 53 process of converting parameter values to Unicode objects - see <a 54 href="parameters-body.html">"Request Body Parameters"</a> and <a 55 href="encodings.html">"Character Encodings"</a> for more discussion of 56 this parameter.</dd> 57 </dl> 58 </div> 59 60 <p>Generally, it is not recommended to just get all parameters since there 61 may be some parameters from the request headers which have the same names as 62 some other parameters from the request body. Consequently, confusion could 63 arise about the significance of various parameter values.</p> 64 </body> 65 </html>