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 Body Parameters</title> 5 <link href="styles.css" rel="stylesheet" type="text/css" /></head> 6 <body> 7 <h1>Request Body Parameters</h1> 8 9 <p>Request parameters are typically added to the request body when forms are 10 submitted by a browser which is instructed to use the <code>POST</code> <a href="methods.html">request method</a>. A Web form (in HTML) can be used to 11 achieve this; for example:</p> 12 <pre><form method="post" 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> 13 14 <p>As a consequence of this form being submitted, the following parameters 15 will become available in the application:</p> 16 <ul> 17 <li><code>param1</code> with the value <code><code>value1</code></code></li> 18 <li><code><code>param2</code></code> with the value <code>value2</code></li> 19 </ul> 20 21 <p>Parameters encoded in this way are not transferred in URLs and are mostly 22 hidden in user interfaces, although viewing a Web page's source can often 23 reveal default values of such parameters.</p> 24 25 <div class="WebStack"> 26 <h3>WebStack API - Accessing Body Parameters</h3> 27 28 <p>Transaction objects provide the following methods to access parameters 29 specified in request headers. The terminology used in the API describes such 30 parameters as body fields, since such parameters are often provided by form 31 fields.</p> 32 <dl> 33 <dt><code>get_fields_from_body</code></dt> 34 <dd>This returns the request parameters (fields) found in the request 35 body (as defined in Web forms). The fields are provided in a dictionary 36 mapping field names to lists of values. Each value will be a Unicode 37 object unless the value represents uploaded file content (see 38 below).<br /> 39 An optional <code>encoding</code> parameter may be used to assist the 40 process of converting parameter values to Unicode objects - see below 41 for a discussion of the issues with this parameter.</dd> 42 </dl> 43 </div> 44 45 <p>Some limitations exist with request body parameters:</p> 46 <ul> 47 <li>For the conversion of such parameters to Unicode to function correctly, 48 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>.</li> 49 </ul> 50 51 <h2>File Uploads</h2> 52 53 <p>One way request body parameters may be used is to provide a mechanism for 54 the uploading of entire files from browsers and other Web clients to 55 applications. Unlike other parameters, those which carry file upload data 56 expose the contents of such uploaded files as <a href="../apidocs/public/WebStack.Helpers.Request.FileContent-class.html"><code>FileContent</code></a> objects 57 instead of Unicode objects.</p> 58 <h3>Unsupported Environments and Framework Issues</h3> 59 <ul> 60 <li>Twisted does not provide file upload data as <a href="../apidocs/public/WebStack.Helpers.Request.FileContent-class.html"><code>FileContent</code></a> objects; 61 instead, file upload data will be decoded and returned as Unicode from 62 WebStack. This behaviour is due to the way Twisted processes the 63 incoming request and may be fixed in a future release.</li> 64 </ul> 65 66 </body></html>