WebStack

docs/methods.html

733:26865b172666
2007-11-12 paulb [project @ 2007-11-12 00:51:34 by paulb] Added a StringResource class for simple static resources. Introduced base classes for common authentication activities. Merged "app", "path" and "qs" fields into a single "app" field for login and redirection. Added support for OpenID authentication.
     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 Methods</title>     5   <link href="styles.css" rel="stylesheet" type="text/css" /></head>     6 <body>     7 <h1>Request Methods</h1>     8      9 <p>In order for an application to behave in the right way when someone sends    10 a request into it, the application must take into consideration the type of    11 request being sent. The type of request is typically referred to as the    12 "request method" and indicates the kind of operation the user is attempting    13 to perform.</p>    14     15 <h2>Common Request Methods</h2>    16     17 <p>The following table summarises the most common methods defined for Web    18 applications in the <a href="http://www.w3.org/Protocols/rfc2616/rfc2616.html">HTTP</a> and <a href="http://www.faqs.org/rfcs/rfc2518.html">WebDAV</a> specifications:</p>    19     20 <table border="1" cellpadding="5" cellspacing="0">    21   <tbody>    22     <tr>    23       <th>Method</th>    24       <th>Type of Operation</th>    25     </tr>    26     <tr>    27       <td>GET</td>    28       <td>Retrieve a Web page or resource</td>    29     </tr>    30     <tr>    31       <td>POST</td>    32       <td>Present information to an application - for example, submission of    33         fields in a form</td>    34     </tr>    35     <tr>    36       <td>PUT</td>    37       <td>Upload a new Web page or resource</td>    38     </tr>    39     <tr>    40       <td>DELETE</td>    41       <td>Delete a Web page or resource</td>    42     </tr>    43     <tr>    44       <td>PROPFIND</td>    45       <td>List resources on a server or in an application</td>    46     </tr>    47   </tbody>    48 </table>    49     50 <p>Most applications will at least need to support the GET request method in    51 order to support some kind of user experience, and those which employ forms    52 in Web pages will most probably want to support the POST request method,    53 too.</p>    54     55 <div class="WebStack">    56 <h3>WebStack API - Discovering the Request Method</h3>    57     58 <p>Transaction objects provide the following method for discovering the    59 request method:</p>    60 <dl>    61   <dt><code>get_request_method</code></dt>    62     <dd>This returns the request method being used in the request being    63       handled.</dd>    64 </dl>    65 </div>    66     67 <h2>Rejecting Certain Request Methods</h2>    68     69 <p>Not all request methods are appropriate to every application. Should a    70 request be received which uses a method not supported by an application, the    71 most appropriate way of responding is to signal this condition to the sender    72 of the request. HTTP provides a response code to communicate just this kind    73 of condition - "405 Method Not Allowed".</p>    74     75 <div class="WebStack">    76 <h3>WebStack API - Signalling Unsupported Methods</h3>    77     78 <p>Transaction objects provide the <code>set_response_code</code> method (as    79 described in <a href="responses.html">"Responses and Presentation"</a>) to    80 communicate critical information on the success or failure of a request. In    81 this case, we would use this method on a transaction object    82 <code>trans</code> as follows:</p>    83 <pre>trans.set_response_code(405)</pre>    84 </div>    85 </body></html>