Additional HTTP Methods
The RWHttpRequest object includes the following identifiers for some HTTP methods:
Identifier
HTTP Method
RWHttpRequest::Connect
CONNECT
RWHttpRequest::Delete
DELETE
RWHttpRequest::Get
GET
RWHttpRequest::Head
HEAD
RWHttpRequest::Options
OPTIONS
RWHttpRequest::Post
POST
RWHttpRequest::Put
PUT
RWHttpRequest::Trace
TRACE
The HTTP specification and the RWHttpRequest class enable you to create custom HTTP methods. Example 11 shows a custom RWHttpRequest based on the custom M-POST HTTP method.
NOTE: Servers and files shown in the code might not exist and are included as examples only.
Example 11 – Creating a custom HTTP method
RWHttpRequestStringBody body("user=sourcepro"); // 1
RWHttpHeaderList headerlist; // 2
RWHttpRequest request("M-POST", "/script.cgi", headerlist,
body); // 3
//1 Constructs an RWHttpRequestStringBody containing the information that is passed to the server as the body of the RWHttpRequest object. A Content-Length header is automatically attached to the request indicating the length of the body object.
//2 Constructs an empty RWHttpHeaderList. Additional headers are not added to the request, but the object is passed as an argument to the RWHttpRequest constructor so that the body can also be passed.
//3 Constructs an RWHttpRequest object that executes an M-POST request to the /script.cgi location with the string user=sourcepro sent to the server as the body of the request.
When submitted to an HTTP server through an RWHttpClient connected to www.perforce.com, the request sends the following data:
 
M-POST /script.cgi HTTP/1.1
Host: www.perforce.com
Content-Length: 14
 
user=sourcepro