SourcePro® API Reference Guide

 
Loading...
Searching...
No Matches
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() [1/3]

RWHttpRequest::RWHttpRequest ( )

Constructs a default RWHttpRequest.

◆ RWHttpRequest() [2/3]

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() [3/3]

RWHttpRequest::RWHttpRequest ( const RWHttpRequest & request)

Copy constructor.

Member Function Documentation

◆ getBody()

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.

◆ getHeaders()

RWHttpHeaderList RWHttpRequest::getHeaders ( ) const
inline

Returns the list of headers associated with self.

◆ getMajorVersion()

int RWHttpRequest::getMajorVersion ( void ) const
inline

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

◆ getMethod()

RWCString RWHttpRequest::getMethod ( void ) const
inline

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

◆ getMinorVersion()

int RWHttpRequest::getMinorVersion ( void ) const
inline

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

◆ getPath()

RWCString RWHttpRequest::getPath ( ) const
inline

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

◆ isValid()

bool RWHttpRequest::isValid ( ) 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.

◆ operator=()

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

Assignment operator.

◆ requestLine()

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.

◆ setBody()

void RWHttpRequest::setBody ( const RWHttpRequestBody & body)
inline

Sets the internal body of the request to body.

◆ setHeaders()

void RWHttpRequest::setHeaders ( const RWHttpHeaderList & headerList)
inline

Sets the internal list of headers to headerList.

◆ setMethod()

void RWHttpRequest::setMethod ( const RWCString & method)
inline

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

◆ setPath()

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.

◆ setVersion()

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 © 2024 Rogue Wave Software, Inc., a Perforce company. All Rights Reserved.