PcapPlusPlus  20.08
pcpp::HttpRequestFirstLine Class Reference

#include <HttpLayer.h>

Classes

class  HttpRequestFirstLineException
 

Public Member Functions

HttpRequestLayer::HttpMethod getMethod () const
 
bool setMethod (HttpRequestLayer::HttpMethod newMethod)
 
std::string getUri () const
 
bool setUri (std::string newUri)
 
HttpVersion getVersion () const
 
void setVersion (HttpVersion newVersion)
 
int getSize () const
 
bool isComplete () const
 

Static Public Member Functions

static HttpRequestLayer::HttpMethod parseMethod (char *data, size_t dataLen)
 

Detailed Description

Represents an HTTP request header first line. The first line includes 3 parameters: HTTP method (e.g GET, POST, etc.), URI (e.g /main/index.html) and HTTP version (e.g HTTP/1.1). All these parameters are included in this class, and the user can retrieve or set them. This class cannot be instantiated by users, it's created inside HttpRequestLayer and user can get a pointer to an instance of it. All "get" methods of this class will retrieve the actual data of the HTTP request and the "set" methods will change the packet data. Since HTTP is a textual protocol, most fields aren't of fixed size and this also applies to the first line parameters. So most "set" methods of this class need in most cases to shorten or extend the data in HttpRequestLayer. These methods will return a false value if this action failed

Member Function Documentation

◆ getMethod()

HttpRequestLayer::HttpMethod pcpp::HttpRequestFirstLine::getMethod ( ) const
inline
Returns
The HTTP method

◆ getSize()

int pcpp::HttpRequestFirstLine::getSize ( ) const
inline
Returns
The size in bytes of the HTTP first line

◆ getUri()

std::string pcpp::HttpRequestFirstLine::getUri ( ) const
Returns
A copied version of the URI (notice changing the return value won't change the actual data of the packet)

◆ getVersion()

HttpVersion pcpp::HttpRequestFirstLine::getVersion ( ) const
inline
Returns
The HTTP version

◆ isComplete()

bool pcpp::HttpRequestFirstLine::isComplete ( ) const
inline

As explained in HttpRequestLayer, an HTTP header can spread over more than 1 packet, so when looking at a single packet the header can be partial. Same goes for the first line - it can spread over more than 1 packet. This method returns an indication whether the first line is partial

Returns
False if the first line is partial, true if it's complete

◆ parseMethod()

static HttpRequestLayer::HttpMethod pcpp::HttpRequestFirstLine::parseMethod ( char *  data,
size_t  dataLen 
)
static

A static method for parsing the HTTP method out of raw data

Parameters
[in]dataThe raw data
[in]dataLenThe raw data length
Returns
The parsed HTTP method

◆ setMethod()

bool pcpp::HttpRequestFirstLine::setMethod ( HttpRequestLayer::HttpMethod  newMethod)

Set the HTTP method

Parameters
[in]newMethodThe method to set
Returns
False if newMethod is HttpRequestLayer::HttpMethodUnknown or if shortening/extending the HttpRequestLayer data failed. True otherwise

◆ setUri()

bool pcpp::HttpRequestFirstLine::setUri ( std::string  newUri)

Set the URI

Parameters
[in]newUriThe URI to set
Returns
False if shortening/extending the HttpRequestLayer data failed. True otherwise

◆ setVersion()

void pcpp::HttpRequestFirstLine::setVersion ( HttpVersion  newVersion)

Set the HTTP version. This method doesn't return a value since all supported HTTP versions are of the same size (HTTP/0.9, HTTP/1.0, HTTP/1.1)

Parameters
[in]newVersionThe HTTP version to set