WebStack

docs/methods.html

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