SourcePro® C++ API Reference Guide

Product Documentation:
   SourcePro C++
Documentation Home
List of all members | Public Member Functions
RWHttpRequest Class Reference

Encapsulates an entire HTTP request including the request line, header list, and request body. More...

#include <rw/http/RWHttpRequest.h>

Public Member Functions

 RWHttpRequest ()
 
 RWHttpRequest (const RWCString &method, const RWCString &path, const RWHttpHeaderList &headers=RWHttpHeaderList(), const RWHttpRequestBody &body=RWHttpRequestStringBody())
 
 RWHttpRequest (const RWHttpRequest &request)
 
RWHttpRequestBodygetBody (void) const
 
RWHttpHeaderList getHeaders () const
 
int getMajorVersion (void) const
 
RWCString getMethod (void) const
 
int getMinorVersion (void) const
 
RWCString getPath () const
 
bool isValid () const
 
RWHttpRequestoperator= (const RWHttpRequest &request)
 
RWCString requestLine (void) const
 
void setBody (const RWHttpRequestBody &body)
 
void setHeaders (const RWHttpHeaderList &headerList)
 
void setMethod (const RWCString &method)
 
void setPath (const RWCString &path)
 
void setVersion (int majorVersion, int minorVersion)
 

Detailed Description

Class RWHttpRequest defines the HTTP request methods in the HTTP specifications. For HTTP/1.1, the commands GET, POST, HEAD, PUT, DELETE, TRACE, and OPTIONS are supported. Class RWHttpRequest enables you to construct a full request and add header information to a request.

Constructor & Destructor Documentation

RWHttpRequest::RWHttpRequest ( )

Constructs a default RWHttpRequest.

RWHttpRequest::RWHttpRequest ( const RWCString method,
const RWCString path,
const RWHttpHeaderList headers = RWHttpHeaderList(),
const RWHttpRequestBody body = RWHttpRequestStringBody() 
)

Accepts the method, path, headers, and body for the request. Both a method and path are required, but a header list and body are optional. The RWCString should contain 7-bit US-ASCII data.

Note
Some methods require a body. If one of those methods is invoked without a body, no error is reported by the HTTP package, but an error should be returned from the server.
RWHttpRequest::RWHttpRequest ( const RWHttpRequest request)

Copy constructor.

Member Function Documentation

RWHttpRequestBody & RWHttpRequest::getBody ( void  ) const
inline

Returns a reference to the internal body object. This method can be used to retrieve the body associated with the request object.

RWHttpHeaderList RWHttpRequest::getHeaders ( ) const
inline

Returns the list of headers associated with self.

int RWHttpRequest::getMajorVersion ( void  ) const
inline

Returns the major portion of the HTTP version. The default value is 1.

RWCString RWHttpRequest::getMethod ( void  ) const
inline

Returns the request type, such as GET. The RWCString should contain 7-bit US-ASCII data.

int RWHttpRequest::getMinorVersion ( void  ) const
inline

Returns the minor portion of the HTTP version. The default value is 1.

RWCString RWHttpRequest::getPath ( ) const
inline

Returns the path associated with the RWHttpRequest. The RWCString should contain 7-bit US-ASCII data.

bool RWHttpRequest::isValid ( void  ) const
inline

Returns true if this is a valid RWHttpRequest object. Otherwise returns false. To be valid, the object must have a method verb and URI associated with it, and the body of the object must be valid.

RWHttpRequest& RWHttpRequest::operator= ( const RWHttpRequest request)

Assignment operator.

RWCString RWHttpRequest::requestLine ( void  ) const

Returns a string representing the Request-Line for this request. It is similar to GET / HTTP/1.1. The RWCString should contain 7-bit US-ASCII data.

void RWHttpRequest::setBody ( const RWHttpRequestBody body)
inline

Sets the internal body of the request to body.

void RWHttpRequest::setHeaders ( const RWHttpHeaderList headerList)
inline

Sets the internal list of headers to headerList.

void RWHttpRequest::setMethod ( const RWCString method)
inline

Sets the request type, such as GET. The RWCString should contain 7-bit US-ASCII data.

void RWHttpRequest::setPath ( const RWCString path)
inline

Sets the target path of the RWHttpRequest to path. The RWCString should contain 7-bit US-ASCII data.

void RWHttpRequest::setVersion ( int  majorVersion,
int  minorVersion 
)
inline

Sets the internal HTTP version that is used in the request. The default version is 1.1.

Copyright © 2016 Rogue Wave Software, Inc. All Rights Reserved.
Rogue Wave and SourcePro are registered trademarks of Rogue Wave Software, Inc. in the United States and other countries. All other trademarks are the property of their respective owners.
Provide feedback to Rogue Wave about its documentation.