WebStack

docs/parameters-body.html

400:5b276bbcbbb5
2005-07-16 paulb [project @ 2005-07-16 20:32:38 by paulb] Changed virtual path info in sub-resources so that it may be an empty string.
     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 Body 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 <h1>Request Body Parameters</h1>    13     14 <p>Request parameters are typically added to the request body when forms are    15 submitted by a browser which is instructed to use the <code>POST</code> <a    16 href="methods.html">request method</a>. A Web form (in HTML) can be used to    17 achieve this; for example:</p>    18 <pre>&lt;form method="POST" action="http://www.boddie.org.uk/application"&gt;    19     &lt;input name="param1" type="text" /&gt;    20     &lt;input name="param2" type="text" /&gt;    21 &lt;/form&gt;</pre>    22     23 <p>As a consequence of this form being submitted, the following parameters    24 will become available in the application:</p>    25 <ul>    26   <li><code>param1</code> with the value <code><code>value1</code></code></li>    27   <li><code><code>param2</code></code> with the value <code>value2</code></li>    28 </ul>    29     30 <p>Parameters encoded in this way are not transferred in URLs and are mostly    31 hidden in user interfaces, although viewing a Web page's source can often    32 reveal default values of such parameters.</p>    33     34 <div class="WebStack">    35 <h3>WebStack API - Accessing Body Parameters</h3>    36     37 <p>Transaction objects provide the following methods to access parameters    38 specified in request headers. The terminology used in the API describes such    39 parameters as body fields, since such parameters are often provided by form    40 fields.</p>    41 <dl>    42   <dt><code>get_fields_from_body</code></dt>    43     <dd>This returns the request parameters (fields) found in the request    44       body (as defined in Web forms). The fields are provided in a dictionary    45       mapping field names to lists of values. Each value will be a Unicode    46       object unless the value represents uploaded file content (see    47       below).<br />    48       An optional <code>encoding</code> parameter may be used to assist the    49       process of converting parameter values to Unicode objects - see below    50       for a discussion of the issues with this parameter.</dd>    51 </dl>    52 </div>    53     54 <p>Some limitations exist with request body parameters:</p>    55 <ul>    56   <li>For the conversion of such parameters to Unicode to function correctly,    57     care must be taken with character encodings - this is discussed in <a    58     href="responses.html">"Responses and Presentation"</a> and also in <a    59     href="encodings.html">"Character Encodings"</a>.</li>    60 </ul>    61     62 <h2>File Uploads</h2>    63     64 <p>One way request body parameters may be used is to provide a mechanism for    65 the uploading of entire files from browsers and other Web clients to    66 applications. Unlike other parameters, those which carry file upload data    67 expose the contents of such uploaded files as plain Python string values    68 instead of Unicode objects.</p>    69 </body>    70 </html>