Request parameters are typically added to the request body when forms are
submitted by a browser which is instructed to use the POST
request method. A Web form (in HTML) can be used to
achieve this; for example:
<form method="post" action="http://www.boddie.org.uk/application">
<input name="param1" type="text" value="value1" />
<input name="param2" type="text" value="value2" />
</form>
As a consequence of this form being submitted, the following parameters will become available in the application:
param1
with the value value1
param2
with the value value2
Parameters encoded in this way are not transferred in URLs and are mostly hidden in user interfaces, although viewing a Web page's source can often reveal default values of such parameters.
Transaction objects provide the following methods to access parameters specified in request headers. The terminology used in the API describes such parameters as body fields, since such parameters are often provided by form fields.
get_fields_from_body
encoding
parameter may be used to assist the
process of converting parameter values to Unicode objects - see below
for a discussion of the issues with this parameter.Some limitations exist with request body parameters:
One way request body parameters may be used is to provide a mechanism for
the uploading of entire files from browsers and other Web clients to
applications. Unlike other parameters, those which carry file upload data
expose the contents of such uploaded files as FileContent
objects
instead of Unicode objects.
FileContent
objects;
instead, file upload data will be decoded and returned as Unicode from
WebStack. This behaviour is due to the way Twisted processes the
incoming request and may be fixed in a future release.