Header used by web browsing applications to transmit information about content type, content length and timestamps for delay statistics. More...
#include "http-header.h"
Public Member Functions | |
HttpHeader () | |
Creates an empty instance . More... | |
HttpHeader () | |
Creates an empty instance . More... | |
void | CreateRequest (const std::string &url, const std::string &method, const std::map< std::string, std::string > ¶meters, const std::vector< std::string > &headers={}) |
void | CreateRequest (const std::string &url, const std::string &method, const std::vector< uint8_t > &body, const std::vector< std::string > &headers) |
void | CreateRequest (const std::string &url, const std::string &method="GET", const std::string &body="", const std::vector< std::string > &headers={}) |
void | CreateResponse (const HttpHeader::HttpStatus status, const std::map< std::string, std::string > &body, const std::vector< std::string > &headers={}) |
void | CreateResponse (const HttpHeader::HttpStatus status, const std::string &body="", const std::vector< std::string > &headers={}) |
void | CreateResponse (const HttpHeader::HttpStatus status, const std::vector< uint8_t > &body, const std::vector< std::string > &headers) |
virtual uint32_t | Deserialize (Buffer::Iterator start) |
virtual uint32_t | Deserialize (Buffer::Iterator start) |
uint32_t | GetContentLength () const |
uint32_t | GetContentSize () |
ContentType_t | GetContentType () const |
uint32_t | GetHeaderSize () |
std::string | GetHeaderString () |
virtual TypeId | GetInstanceTypeId () const |
Get the most derived TypeId for this Object. More... | |
virtual TypeId | GetInstanceTypeId () const |
Get the most derived TypeId for this Object. More... | |
HttpMethod | GetMethod () const |
HttpMethod | GetMethod () const |
std::vector< uint8_t > | GetPayload () |
std::string | GetPayloadString () |
std::string | GetRequestUri () const |
virtual uint32_t | GetSerializedSize () const |
virtual uint32_t | GetSerializedSize () const |
uint32_t | GetSize () const |
uint64_t | GetSize (void) const |
Get the size information that the header is carrying. More... | |
HttpStatus | GetStatus () const |
HttpStatus | GetStatus () const |
std::string | GetStatusString () const |
std::string | GetUri () const |
std::string | GetUri () const |
bool | IsFragmented () |
void | ParseResponse () |
virtual void | Print (std::ostream &os) const |
virtual void | Print (std::ostream &os) const |
virtual void | Serialize (Buffer::Iterator start) const |
virtual void | Serialize (Buffer::Iterator start) const |
void | SetContentLength (uint32_t contentLength) |
void | SetContentType (ContentType_t contentType) |
void | SetHeaderString (std::string input) |
void | SetMethod (const std::string &m) |
void | SetMethod (HttpMethod method) |
void | SetMethod (HttpMethod method) |
void | SetSize (uint64_t size) |
Set the size information that the header will carry. More... | |
void | SetStatus (HttpStatus status) |
void | SetStatus (HttpStatus status) |
void | SetUri (const std::string &url) |
void | SetUri (std::string uri) |
std::string | ToString () const |
std::string | ToString () const |
std::string | urlEncode (const std::string &str) |
Public Member Functions inherited from ns3::Header | |
~Header () override | |
virtual uint32_t | Deserialize (Buffer::Iterator start)=0 |
Deserialize the object from a buffer iterator. More... | |
virtual uint32_t | Deserialize (Buffer::Iterator start, Buffer::Iterator end) |
Deserialize the object from a buffer iterator. More... | |
Public Member Functions inherited from ns3::Chunk | |
virtual uint32_t | Deserialize (Buffer::Iterator start, Buffer::Iterator end) |
Deserialize the object from a buffer iterator. More... | |
Public Member Functions inherited from ns3::ObjectBase | |
virtual | ~ObjectBase () |
Virtual destructor. More... | |
void | GetAttribute (std::string name, AttributeValue &value) const |
Get the value of an attribute, raising fatal errors if unsuccessful. More... | |
bool | GetAttributeFailSafe (std::string name, AttributeValue &value) const |
Get the value of an attribute without raising errors. More... | |
void | SetAttribute (std::string name, const AttributeValue &value) |
Set a single attribute, raising fatal errors if unsuccessful. More... | |
bool | SetAttributeFailSafe (std::string name, const AttributeValue &value) |
Set a single attribute without raising errors. More... | |
bool | TraceConnect (std::string name, std::string context, const CallbackBase &cb) |
Connect a TraceSource to a Callback with a context. More... | |
bool | TraceConnectWithoutContext (std::string name, const CallbackBase &cb) |
Connect a TraceSource to a Callback without a context. More... | |
bool | TraceDisconnect (std::string name, std::string context, const CallbackBase &cb) |
Disconnect from a TraceSource a Callback previously connected with a context. More... | |
bool | TraceDisconnectWithoutContext (std::string name, const CallbackBase &cb) |
Disconnect from a TraceSource a Callback previously connected without a context. More... | |
Static Public Member Functions | |
static TypeId | GetTypeId () |
Returns the object TypeId. More... | |
static TypeId | GetTypeId () |
Returns the object TypeId. More... | |
Static Public Member Functions inherited from ns3::Header | |
static TypeId | GetTypeId () |
Get the type ID. More... | |
Static Public Member Functions inherited from ns3::Chunk | |
static TypeId | GetTypeId () |
Get the type ID. More... | |
Static Public Member Functions inherited from ns3::ObjectBase | |
static TypeId | GetTypeId () |
Get the type ID. More... | |
Private Attributes | |
std::vector< uint8_t > | m_allData |
uint32_t | m_contentLength |
" Content length field (in bytes unit). More... | |
uint16_t | m_contentType |
" Content type field in integer format. More... | |
std::string | m_domain |
bool | m_fragmented |
std::vector< std::string > | m_headers |
uint32_t | m_headerSize |
uint16_t | m_method |
" Connection method field in integer format. More... | |
std::string | m_path |
std::vector< uint8_t > | m_payload |
std::string | m_request_uri |
std::string | m_scheme |
uint64_t | m_size {0} |
The 'size' information that the header is carrying. More... | |
uint16_t | m_status |
" Connection status field in integer format. More... | |
std::string | m_uri |
std::vector< std::string > | uriParams |
Additional Inherited Members | |
Protected Member Functions inherited from ns3::ObjectBase | |
void | ConstructSelf (const AttributeConstructionList &attributes) |
Complete construction of ObjectBase; invoked by derived classes. More... | |
virtual void | NotifyConstructionCompleted () |
Notifier called once the ObjectBase is fully constructed. More... | |
Related Functions inherited from ns3::ObjectBase | |
static TypeId | GetObjectIid () |
Ensure the TypeId for ObjectBase gets fully configured to anchor the inheritance tree properly. More... | |
Header used by web browsing applications to transmit information about content type, content length and timestamps for delay statistics.
The header contains the following fields (and their respective size when serialized):
The header is attached to every packet transmitted by HttpClient and HttpServer applications. In received, split packets, only the first packet of transmitted object contains the header, which helps to identify how many bytes are left to be received.
The last 2 fields allow the applications to compute the propagation delay of each packet. The client TS field indicates the time when the request packet is sent by the HttpClient, while the server TS field indicates the time when the response packet is sent by the HttpServer.
Definition at line 56 of file http-header.h.
The possible types of content (default = NOT_SET).
Definition at line 83 of file http-header.h.
The possible types of content (default = NOT_SET).
Definition at line 62 of file http-header.h.
Definition at line 90 of file http-header.h.
Definition at line 69 of file http-header.h.
Definition at line 99 of file http-header.h.
Definition at line 78 of file http-header.h.
ns3::HttpHeader::HttpHeader | ( | ) |
Creates an empty instance .
Definition at line 33 of file http-header.cc.
References NS_LOG_FUNCTION.
ns3::HttpHeader::HttpHeader | ( | ) |
Creates an empty instance .
void ns3::HttpHeader::CreateRequest | ( | const std::string & | url, |
const std::string & | method, | ||
const std::map< std::string, std::string > & | parameters, | ||
const std::vector< std::string > & | headers = {} |
||
) |
Definition at line 44 of file http-header.cc.
References NS_LOG_FUNCTION, and http::urlEncode().
void ns3::HttpHeader::CreateRequest | ( | const std::string & | url, |
const std::string & | method, | ||
const std::vector< uint8_t > & | body, | ||
const std::vector< std::string > & | headers | ||
) |
Definition at line 84 of file http-header.cc.
References NS_LOG_FUNCTION, and nlohmann::to_string().
void ns3::HttpHeader::CreateRequest | ( | const std::string & | url, |
const std::string & | method = "GET" , |
||
const std::string & | body = "" , |
||
const std::vector< std::string > & | headers = {} |
||
) |
Definition at line 67 of file http-header.cc.
References NS_LOG_FUNCTION.
void ns3::HttpHeader::CreateResponse | ( | const HttpHeader::HttpStatus | status, |
const std::map< std::string, std::string > & | body, | ||
const std::vector< std::string > & | headers = {} |
||
) |
void ns3::HttpHeader::CreateResponse | ( | const HttpHeader::HttpStatus | status, |
const std::string & | body = "" , |
||
const std::vector< std::string > & | headers = {} |
||
) |
Definition at line 141 of file http-header.cc.
void ns3::HttpHeader::CreateResponse | ( | const HttpHeader::HttpStatus | status, |
const std::vector< uint8_t > & | body, | ||
const std::vector< std::string > & | headers | ||
) |
Definition at line 154 of file http-header.cc.
References NS_LOG_FUNCTION, and nlohmann::to_string().
|
virtual |
start | an iterator which points to where the header should read from. |
This method is used by Packet::RemoveHeader to re-create a header from the byte buffer of a packet. The data read is expected to match bit-for-bit the representation of this header in real networks.
Note that data is not actually removed from the buffer to which the iterator points. Both Packet::RemoveHeader() and Packet::PeekHeader() call Deserialize(), but only the RemoveHeader() has additional statements to remove the header bytes from the underlying buffer and associated metadata.
Implements ns3::Header.
Definition at line 91 of file http-header.cc.
References ns3::Buffer::Iterator::GetDistanceFrom(), GetSerializedSize(), m_contentLength, m_contentType, m_method, m_size, m_status, m_uri, NS_ASSERT, NS_LOG_FUNCTION, ns3::Buffer::Iterator::Read(), ns3::Buffer::Iterator::ReadU16(), ns3::Buffer::Iterator::ReadU32(), ns3::Buffer::Iterator::ReadU64(), and two-ray-to-three-gpp-ch-calibration::start.
|
virtual |
start | an iterator which points to where the header should read from. |
This method is used by Packet::RemoveHeader to re-create a header from the byte buffer of a packet. The data read is expected to match bit-for-bit the representation of this header in real networks.
Note that data is not actually removed from the buffer to which the iterator points. Both Packet::RemoveHeader() and Packet::PeekHeader() call Deserialize(), but only the RemoveHeader() has additional statements to remove the header bytes from the underlying buffer and associated metadata.
Implements ns3::Header.
uint32_t ns3::HttpHeader::GetContentLength | ( | ) | const |
Definition at line 192 of file http-header.cc.
References m_contentLength.
uint32_t ns3::HttpHeader::GetContentSize | ( | ) |
Definition at line 581 of file http-header.cc.
References NS_LOG_FUNCTION.
HttpHeader::ContentType_t ns3::HttpHeader::GetContentType | ( | ) | const |
Definition at line 162 of file http-header.cc.
References EMBEDDED_OBJECT, m_contentType, MAIN_OBJECT, NOT_SET, and NS_FATAL_ERROR.
uint32_t ns3::HttpHeader::GetHeaderSize | ( | ) |
Definition at line 576 of file http-header.cc.
std::string ns3::HttpHeader::GetHeaderString | ( | ) |
Definition at line 410 of file http-header.cc.
References NS_LOG_FUNCTION.
|
virtual |
Get the most derived TypeId for this Object.
This method is typically implemented by ns3::Object::GetInstanceTypeId but some classes which derive from ns3::ObjectBase directly have to implement it themselves.
Implements ns3::ObjectBase.
Definition at line 54 of file http-header.cc.
References GetTypeId().
|
virtual |
Get the most derived TypeId for this Object.
This method is typically implemented by ns3::Object::GetInstanceTypeId but some classes which derive from ns3::ObjectBase directly have to implement it themselves.
Implements ns3::ObjectBase.
HttpHeader::HttpMethod ns3::HttpHeader::GetMethod | ( | ) | const |
Definition at line 649 of file http-header.cc.
References DELETE, GET, HEAD, m_method, NS_FATAL_ERROR, PATCH, POST, and PUT.
HttpMethod ns3::HttpHeader::GetMethod | ( | ) | const |
|
inline |
Definition at line 210 of file http-header.h.
References m_payload.
|
inline |
Definition at line 214 of file http-header.h.
References m_headers, m_payload, and ParseResponse().
std::string ns3::HttpHeader::GetRequestUri | ( | ) | const |
Definition at line 1282 of file http-header.cc.
|
virtual |
This method is used by Packet::AddHeader to store a header into the byte buffer of a packet. This method should return the number of bytes which are needed to store the full header data by Serialize.
Implements ns3::Header.
Definition at line 60 of file http-header.cc.
References m_contentLength.
Referenced by Deserialize().
|
virtual |
This method is used by Packet::AddHeader to store a header into the byte buffer of a packet. This method should return the number of bytes which are needed to store the full header data by Serialize.
Implements ns3::Header.
uint32_t ns3::HttpHeader::GetSize | ( | ) | const |
uint32_t ns3::HttpHeader::GetSize | ( | void | ) | const |
Get the size information that the header is carrying.
Definition at line 205 of file http-header.cc.
References m_size.
HttpHeader::HttpStatus ns3::HttpHeader::GetStatus | ( | ) | const |
Definition at line 414 of file http-header.cc.
References Accepted, AlreadyReported, BadGateway, BadRequest, Conflict, Continue, Created, EarlyHints, ExpectationFailed, FailedDependency, Forbidden, Found, GatewayTimeout, Gone, HttpVersionNotSupported, ImaTeapot, ImUsed, InsufficientStorage, InternalServerError, LengthRequired, Locked, LoopDetected, m_status, MethodNotAllowed, MisdirectedRequest, MovedPermanently, MultipleChoice, MultiStatus, NetworkAuthenticationRequired, NoContent, NonAuthoritativeInformation, NotAcceptable, NotExtended, NotFound, NotImplemented, NotModified, NS_FATAL_ERROR, Ok, PartialContent, PayloadTooLarge, PaymentRequired, PermanentRedirect, PreconditionFailed, PreconditionRequired, Processing, ProxyAuthenticationRequired, RangeNotSatisfiable, RequestHeaderFieldsTooLarge, RequestTimeout, ResetContent, SeeOther, ServiceUnavailable, SwitchingProtocol, TemporaryRedirect, TooEarly, TooManyRequests, Unauthorized, UnavailableForLegalReasons, UnprocessableEntity, UnsupportedMediaType, UpgradeRequired, UriTooLong, UseProxy, and VariantAlsoNegotiates.
HttpStatus ns3::HttpHeader::GetStatus | ( | ) | const |
std::string ns3::HttpHeader::GetStatusString | ( | ) | const |
Definition at line 999 of file http-header.cc.
References NS_FATAL_ERROR.
|
static |
Returns the object TypeId.
Definition at line 44 of file http-header.cc.
References ns3::TypeId::SetParent().
Referenced by GetInstanceTypeId().
|
static |
std::string ns3::HttpHeader::GetUri | ( | ) | const |
std::string ns3::HttpHeader::GetUri | ( | ) | const |
|
inline |
Definition at line 275 of file http-header.h.
References m_fragmented.
void ns3::HttpHeader::ParseResponse | ( | ) |
Definition at line 204 of file http-header.cc.
References min, NS_FATAL_ERROR, and NS_LOG_FUNCTION.
Referenced by GetPayloadString().
|
virtual |
os | output stream This method is used by Packet::Print to print the content of a header as ascii data to a c++ output stream. Although the header is free to format its output as it wishes, it is recommended to follow a few rules to integrate with the packet pretty printer: start with flags, small field values located between a pair of parens. Values should be separated by whitespace. Follow the parens with the important fields, separated by whitespace. i.e.: (field1 val1 field2 val2 field3 val3) field4 val4 field5 val5 |
Implements ns3::Header.
Definition at line 121 of file http-header.cc.
References m_contentLength, m_contentType, m_method, m_status, m_uri, and NS_LOG_FUNCTION.
Referenced by ToString().
|
virtual |
os | output stream This method is used by Packet::Print to print the content of a header as ascii data to a c++ output stream. Although the header is free to format its output as it wishes, it is recommended to follow a few rules to integrate with the packet pretty printer: start with flags, small field values located between a pair of parens. Values should be separated by whitespace. Follow the parens with the important fields, separated by whitespace. i.e.: (field1 val1 field2 val2 field3 val3) field4 val4 field5 val5 |
Implements ns3::Header.
|
virtual |
start | an iterator which points to where the header should be written. |
This method is used by Packet::AddHeader to store a header into the byte buffer of a packet. The data written is expected to match bit-for-bit the representation of this header in a real network.
Implements ns3::Header.
Definition at line 69 of file http-header.cc.
References m_contentLength, m_contentType, m_method, m_size, m_status, m_uri, NS_LOG_FUNCTION, and two-ray-to-three-gpp-ch-calibration::start.
|
virtual |
start | an iterator which points to where the header should be written. |
This method is used by Packet::AddHeader to store a header into the byte buffer of a packet. The data written is expected to match bit-for-bit the representation of this header in a real network.
Implements ns3::Header.
void ns3::HttpHeader::SetContentLength | ( | uint32_t | contentLength | ) |
contentLength | The content length (in bytes). |
Definition at line 184 of file http-header.cc.
References m_contentLength, and NS_LOG_FUNCTION.
Referenced by SetUri().
void ns3::HttpHeader::SetContentType | ( | HttpHeader::ContentType_t | contentType | ) |
contentType | The content type. |
Definition at line 141 of file http-header.cc.
References EMBEDDED_OBJECT, m_contentType, MAIN_OBJECT, NOT_SET, NS_FATAL_ERROR, and NS_LOG_FUNCTION.
void ns3::HttpHeader::SetHeaderString | ( | std::string | input | ) |
Definition at line 421 of file http-header.cc.
References NS_LOG_FUNCTION.
void ns3::HttpHeader::SetMethod | ( | const std::string & | m | ) |
Definition at line 1141 of file http-header.cc.
References two-ray-to-three-gpp-ch-calibration::m, NS_FATAL_ERROR, and NS_LOG_FUNCTION.
void ns3::HttpHeader::SetMethod | ( | HttpHeader::HttpMethod | method | ) |
method | The connection method. |
Definition at line 617 of file http-header.cc.
References DELETE, GET, HEAD, m_method, NS_FATAL_ERROR, NS_LOG_FUNCTION, PATCH, POST, and PUT.
void ns3::HttpHeader::SetMethod | ( | HttpMethod | method | ) |
method | The connection method. |
void ns3::HttpHeader::SetSize | ( | uint64_t | size | ) |
Set the size information that the header will carry.
size | the size |
Definition at line 199 of file http-header.cc.
References m_size.
void ns3::HttpHeader::SetStatus | ( | HttpHeader::HttpStatus | status | ) |
status | The connection status. |
Definition at line 211 of file http-header.cc.
References Accepted, AlreadyReported, BadGateway, BadRequest, Conflict, Continue, Created, EarlyHints, ExpectationFailed, FailedDependency, Forbidden, Found, GatewayTimeout, Gone, HttpVersionNotSupported, ImaTeapot, ImUsed, InsufficientStorage, InternalServerError, LengthRequired, Locked, LoopDetected, m_status, MethodNotAllowed, MisdirectedRequest, MovedPermanently, MultipleChoice, MultiStatus, NetworkAuthenticationRequired, NoContent, NonAuthoritativeInformation, NotAcceptable, NotExtended, NotFound, NotImplemented, NotModified, NS_FATAL_ERROR, NS_LOG_FUNCTION, Ok, PartialContent, PayloadTooLarge, PaymentRequired, PermanentRedirect, PreconditionFailed, PreconditionRequired, Processing, ProxyAuthenticationRequired, RangeNotSatisfiable, RequestHeaderFieldsTooLarge, RequestTimeout, ResetContent, SeeOther, ServiceUnavailable, SwitchingProtocol, TemporaryRedirect, TooEarly, TooManyRequests, Unauthorized, UnavailableForLegalReasons, UnprocessableEntity, UnsupportedMediaType, UpgradeRequired, UriTooLong, UseProxy, and VariantAlsoNegotiates.
void ns3::HttpHeader::SetStatus | ( | HttpStatus | status | ) |
status | The connection status. |
void ns3::HttpHeader::SetUri | ( | const std::string & | url | ) |
std::string | The uri. |
Definition at line 1287 of file http-header.cc.
References NS_LOG_FUNCTION.
void ns3::HttpHeader::SetUri | ( | std::string | uri | ) |
std::string | The uri. |
Definition at line 687 of file http-header.cc.
References m_uri, NS_LOG_FUNCTION, and SetContentLength().
std::string ns3::HttpHeader::ToString | ( | ) | const |
Definition at line 132 of file http-header.cc.
References NS_LOG_FUNCTION, and Print().
std::string ns3::HttpHeader::ToString | ( | ) | const |
std::string ns3::HttpHeader::urlEncode | ( | const std::string & | str | ) |
Definition at line 1229 of file http-header.cc.
|
private |
Definition at line 287 of file http-header.h.
|
private |
" Content length field (in bytes unit).
Definition at line 235 of file http-header.h.
Referenced by Deserialize(), GetContentLength(), GetSerializedSize(), Print(), Serialize(), and SetContentLength().
|
private |
" Content type field in integer format.
Definition at line 234 of file http-header.h.
Referenced by Deserialize(), GetContentType(), Print(), Serialize(), and SetContentType().
|
private |
Definition at line 282 of file http-header.h.
|
private |
Definition at line 295 of file http-header.h.
Referenced by IsFragmented().
|
private |
Definition at line 285 of file http-header.h.
Referenced by GetPayloadString().
|
private |
Definition at line 293 of file http-header.h.
|
private |
" Connection method field in integer format.
Definition at line 232 of file http-header.h.
Referenced by Deserialize(), GetMethod(), Print(), Serialize(), and SetMethod().
|
private |
Definition at line 283 of file http-header.h.
|
private |
Definition at line 286 of file http-header.h.
Referenced by GetPayload(), and GetPayloadString().
|
private |
Definition at line 298 of file http-header.h.
|
private |
Definition at line 281 of file http-header.h.
|
private |
The 'size' information that the header is carrying.
Definition at line 236 of file http-header.h.
Referenced by Deserialize(), GetSize(), Serialize(), and SetSize().
|
private |
" Connection status field in integer format.
Definition at line 233 of file http-header.h.
Referenced by Deserialize(), GetStatus(), Print(), Serialize(), and SetStatus().
|
private |
Definition at line 237 of file http-header.h.
Referenced by Deserialize(), GetUri(), Print(), Serialize(), and SetUri().
|
private |
Definition at line 238 of file http-header.h.