PcapPlusPlus  20.08+
pcpp::HttpMessage Class Reference

#include <HttpLayer.h>

Inheritance diagram for pcpp::HttpMessage:
pcpp::TextBasedProtocolMessage pcpp::Layer pcpp::IDataContainer pcpp::HttpRequestLayer pcpp::HttpResponseLayer

Public Member Functions

virtual HeaderFieldaddField (const std::string &fieldName, const std::string &fieldValue)
 
virtual HeaderFieldaddField (const HeaderField &newField)
 
virtual HeaderFieldinsertField (HeaderField *prevField, const std::string &fieldName, const std::string &fieldValue)
 
virtual HeaderFieldinsertField (HeaderField *prevField, const HeaderField &newField)
 
OsiModelLayer getOsiModelLayer () const
 
- Public Member Functions inherited from pcpp::TextBasedProtocolMessage
HeaderFieldgetFieldByName (std::string fieldName, int index=0) const
 
HeaderFieldgetFirstField () const
 
HeaderFieldgetNextField (HeaderField *prevField) const
 
int getFieldCount () const
 
HeaderFieldaddEndOfHeader ()
 
virtual HeaderFieldinsertField (std::string prevFieldName, const std::string &fieldName, const std::string &fieldValue)
 
bool removeField (HeaderField *fieldToRemove)
 
bool removeField (std::string fieldName, int index=0)
 
bool isHeaderComplete () const
 
virtual void parseNextLayer ()
 
size_t getHeaderLen () const
 
virtual void computeCalculateFields ()
 
- Public Member Functions inherited from pcpp::Layer
virtual ~Layer ()
 
LayergetNextLayer () const
 
LayergetPrevLayer () const
 
ProtocolType getProtocol () const
 
uint8_t * getData () const
 
size_t getDataLen () const
 
uint8_t * getLayerPayload () const
 
size_t getLayerPayloadSize () const
 
bool isAllocatedToPacket () const
 
void copyData (uint8_t *toArr) const
 
uint8_t * getDataPtr (size_t offset=0) const
 
virtual std::string toString () const =0
 

Static Public Member Functions

static bool isHttpPort (uint16_t port)
 

Detailed Description

Represents a general HTTP message. It's an abstract class and cannot be instantiated. It's inherited by HttpRequestLayer and HttpResponseLayer

Member Function Documentation

◆ addField() [1/2]

virtual HeaderField* pcpp::HttpMessage::addField ( const std::string &  fieldName,
const std::string &  fieldValue 
)
virtual

Add a new header field to this message. This field will be added last (before the end-of-header field)

Parameters
[in]fieldNameThe field name
[in]fieldValueThe field value
Returns
A pointer to the newly created header field, or NULL if the field could not be created

Reimplemented from pcpp::TextBasedProtocolMessage.

◆ addField() [2/2]

virtual HeaderField* pcpp::HttpMessage::addField ( const HeaderField newField)
virtual

Add a new header field to this message. This field will be added last (before the end-of-header field)

Parameters
[in]newFieldThe header field to add
Returns
A pointer to the newly created header field, or NULL if the field could not be created

Reimplemented from pcpp::TextBasedProtocolMessage.

◆ getOsiModelLayer()

OsiModelLayer pcpp::HttpMessage::getOsiModelLayer ( ) const
inlinevirtual
Returns
The OSI Model layer this protocol belongs to

Implements pcpp::Layer.

◆ insertField() [1/2]

virtual HeaderField* pcpp::HttpMessage::insertField ( HeaderField prevField,
const std::string &  fieldName,
const std::string &  fieldValue 
)
virtual

Insert a new field after an existing field

Parameters
[in]prevFieldA pointer to the existing field. If it's NULL the new field will be added as first field
[in]fieldNameThe field name
[in]fieldValueThe field value
Returns
A pointer to the newly created header field, or NULL if the field could not be created

Reimplemented from pcpp::TextBasedProtocolMessage.

◆ insertField() [2/2]

virtual HeaderField* pcpp::HttpMessage::insertField ( HeaderField prevField,
const HeaderField newField 
)
virtual

Insert a new field after an existing field

Parameters
[in]prevFieldA pointer to the existing field
[in]newFieldThe header field to add
Returns
A pointer to the newly created header field, or NULL if the field could not be created

Reimplemented from pcpp::TextBasedProtocolMessage.

◆ isHttpPort()

static bool pcpp::HttpMessage::isHttpPort ( uint16_t  port)
inlinestatic

A static method that checks whether the port is considered as HTTP

Parameters
[in]portThe port number to be checked