Request Methods

In order for an application to behave in the right way when someone sends a request into it, the application must take into consideration the type of request being sent. The type of request is typically referred to as the "request method" and indicates the kind of operation the user is attempting to perform.

Common Request Methods

The following table summarises the most common methods defined for Web applications in the HTTP and WebDAV specifications:

Method Type of Operation
GET Retrieve a Web page or resource
POST Present information to an application - for example, submission of fields in a form
PUT Upload a new Web page or resource
DELETE Delete a Web page or resource
PROPFIND List resources on a server or in an application

Most applications will at least need to support the GET request method in order to support some kind of user experience, and those which employ forms in Web pages will most probably want to support the POST request method, too.

WebStack API - Discovering the Request Method

Transaction objects provide the following method for discovering the request method:

get_request_method
This returns the request method being used in the request being handled.

Rejecting Certain Request Methods

Not all request methods are appropriate to every application. Should a request be received which uses a method not supported by an application, the most appropriate way of responding is to signal this condition to the sender of the request. HTTP provides a response code to communicate just this kind of condition - "405 Method Not Allowed".

WebStack API - Signalling Unsupported Methods

Transaction objects provide the set_response_code method (as described in "Responses and Presentation") to communicate critical information on the success or failure of a request. In this case, we would use this method on a transaction object trans as follows:

trans.set_response_code(405)