The basic class to represent both HTTP requests and responses. More...
#include "http.h"
Collaboration diagram for ns3::HTTPMessage:Public Member Functions | |
| void | CreateRequest (const std::string &url, const std::string &method) |
| void | CreateRequest (const std::string &url, const std::string &method, const std::string &body) |
| void | CreateRequest (const std::string &url, const std::string &method, const std::vector< uint8_t > &body) |
| void | CreateResponse (const HttpStatus status) |
| void | CreateResponse (const HttpStatus status, const std::string &body) |
| void | CreateResponse (const HttpStatus status, const std::string &body, const std::unordered_map< std::string, std::string > &headers) |
| void | CreateResponse (const HttpStatus status, const std::vector< uint8_t > &body) |
| void | CreateResponse (const HttpStatus status, const std::vector< uint8_t > &body, const std::unordered_map< std::string, std::string > &headers) |
| size_t | GetContentLength () const |
| Return the size of the binary body vector. | |
| std::string | GetHeader (const std::string &name) const |
| Get the string value of a single header from the message. | |
| uint32_t | GetHeadersSize () |
| std::vector< uint8_t > & | GetMessageBody () |
| Get the body vector for this message. | |
| std::string | GetMessageBodyString () |
| HTTPMessage::HttpMethod | GetMethod () const |
| std::string | GetMethodToString () const |
| std::string | GetPath () const |
| Grab the current associated path of this message. | |
| std::string | GetRequestUri () const |
| uint32_t | GetSize () |
| HTTPMessage::HttpStatus | GetStatus () const |
| To be returned with a status code in a response is a status text describing the status code by text rather than by a code. | |
| uint16_t | GetStatusCode () const |
| Get the status code for this message. | |
| std::string | GetStatusMessage () const |
| Get the current status message for this message. | |
| std::string | GetUri () const |
| Grab the uri. | |
| std::string | GetVersion () const |
| Get the current HTTP version for this message. | |
| size_t | HeaderCount () |
| Return the amount of headers in the message. | |
| bool | IsFragmented () const |
| void | SetFragmented (bool value) |
| HTTPMessage & | SetHeader (const std::string &name, const std::string &value) |
| Set a header in the map to the value provided. | |
| HTTPMessage & | SetHeaders (const std::unordered_map< std::string, std::string > &headers) |
| Set a number of headers based on a generic map of keys and values. | |
| void | SetMessageBody (const std::string &body) |
| Set the body of this message to a string value. | |
| void | SetMessageBody (const std::vector< uint8_t > &body) |
| Set the body of this message to an unsigned 8-bit binary value. | |
| void | SetMethod (const std::string &m) |
| Set the associated message method for this message. | |
| void | SetPath (const std::string &url) |
| Set the path of this message, which will be used if it is a request. | |
| void | SetStatusCode (uint16_t code) |
| Set the status code of this HTTP message. | |
| void | SetStatusMessage (const std::string &message) |
| Set the status message of this HTTP message. | |
| void | SetVersion (const std::string &version) |
| Set the version of this HTTP message to the string specified. | |
| std::string | StatusTextFromStatusCode (const uint16_t statusCode) |
| To be returned with a status code in a response is a status text describing the status code by text rather than by a code. | |
| std::string | ToString () |
Takes the headers added to the message along with the body and outputs it to a std::string for use in client/server HTTP messages. | |
Private Attributes | |
| std::vector< uint8_t > | m_body |
| A vector of unsigned 8-bit integers used to store message bodies. | |
| uint32_t | m_contentLength = 0 |
| std::string | m_domain |
| bool | m_fragmented = false |
| Whether the payload size is less then content-length. | |
| std::unordered_map< std::string, std::string > | m_headers |
An unordered_map of headers using a std::string for both the key and the value. | |
| uint32_t | m_headersLength = 0 |
| HTTPMessage::HttpMethod | m_method = HTTPMessage::HttpMethod::NONE |
| The HTTP method for this message. | |
| std::string | m_path = "" |
| The path for the resource specified in the message. | |
| std::string | m_request_uri |
| std::string | m_scheme |
| uint16_t | m_statusCode = 0 |
| A status code for this message. | |
| std::string | m_statusMessage = "" |
| A status message to be associated with the status code for this message. | |
| std::string | m_uri |
| std::string | m_version = HTTPVersion11 |
| The version used for this HTTP message as a string. | |
The basic class to represent both HTTP requests and responses.
Contains a method for grabbing the message as a string formatted for sending through a server or other means.
Allows for setting a message body that is represented by a vector of 8-bit unsigned integers. This is to allow binary data to be sent through the message. But, you also can use the included methods to send plain strings.
This class returns as many methods as possible with a reference to the current object, to try and allow for chaining methods.
Note: for convenience, the header for Content-Length is automatically included as it is grabbed from the m_body member. Though, it is only included if the body member isn't empty.
Definition at line 735 of file http.h.
References ns3::Create(), and CreateRequest().
Referenced by ns3::QKDApp004::Close(), CreateRequest(), CreateRequest(), ns3::QKDApp004::EstablishQueues(), ns3::QKDKeyManagerSystemApplication::Fill(), ns3::QKDApp004::GetKeyFromKMS(), ns3::QKDApp014::GetKeysFromKMS(), ns3::QKDApp014::GetKeyWithKeyIDs(), ns3::QKDApp014::GetStatusFromKMS(), ns3::QKDKeyManagerSystemApplication::NewAppRequest(), ns3::QKDApp004::OpenConnect(), ns3::QKDKeyManagerSystemApplication::ProcessCloseRequest(), ns3::QKDKeyManagerSystemApplication::ProcessRelayRequest(), ns3::QKDKeyManagerSystemApplication::RegisterRequest(), ns3::QKDKeyManagerSystemApplication::Relay(), ns3::QKDApp014::SendKeyIds(), and ns3::QKDApp004::SendKsid().
Here is the call graph for this function:
Here is the caller graph for this function:
|
inline |
Definition at line 747 of file http.h.
References ns3::Create(), and CreateRequest().
Here is the call graph for this function:
|
inline |
Definition at line 760 of file http.h.
References ns3::Create(), m_domain, SetHeader(), SetMessageBody(), SetMethod(), and SetPath().
Here is the call graph for this function:
|
inline |
Definition at line 781 of file http.h.
References CreateResponse().
Referenced by CreateResponse(), CreateResponse(), CreateResponse(), CreateResponse(), ns3::QKDApp004::EstablishQueues(), ns3::QKDKeyManagerSystemApplication::ProcessFillRequest(), ns3::QKDKeyManagerSystemApplication::ProcessGetKey004Request(), ns3::QKDKeyManagerSystemApplication::ProcessKMSCloseRequest(), ns3::QKDKeyManagerSystemApplication::ProcessNewAppRequest(), ns3::QKDKeyManagerSystemApplication::ProcessNewAppResponse(), ns3::QKDKeyManagerSystemApplication::ProcessOpenConnectRequest(), ns3::QKDKeyManagerSystemApplication::ProcessRegisterRequest(), ns3::QKDKeyManagerSystemApplication::ProcessRelayRequest(), ns3::QKDKeyManagerSystemApplication::ProcessRelayResponse(), ns3::QKDKeyManagerSystemApplication::ProcessRequest(), ns3::QKDKeyManagerSystemApplication::ProcessSKeyCreateRequest(), ns3::QKDApp014::SendKeyIds(), and ns3::QKDApp004::SendKsid().
Here is the call graph for this function:
Here is the caller graph for this function:
|
inline |
Definition at line 790 of file http.h.
References ns3::Create(), and CreateResponse().
Here is the call graph for this function:
|
inline |
Definition at line 817 of file http.h.
References ns3::Create(), CreateResponse(), and SetHeaders().
Here is the call graph for this function:
|
inline |
Definition at line 800 of file http.h.
References ns3::Create(), SetHeader(), SetMessageBody(), SetMethod(), and SetStatusCode().
Here is the call graph for this function:
|
inline |
Definition at line 829 of file http.h.
References ns3::Create(), CreateResponse(), and SetHeaders().
Here is the call graph for this function:
|
inline |
Return the size of the binary body vector.
Definition at line 722 of file http.h.
References m_contentLength.
Referenced by GetSize(), ns3::QKDKeyManagerSystemApplication::PacketReceivedKMSs(), and ns3::HTTPMessageParser::Parse().
Here is the caller graph for this function:
|
inline |
|
inline |
Definition at line 680 of file http.h.
References m_headersLength, and ToString().
Referenced by GetSize().
Here is the call graph for this function:
Here is the caller graph for this function:
|
inline |
Get the body vector for this message.
Definition at line 708 of file http.h.
References m_body.
Referenced by ns3::HTTPMessageParser::Parse().
Here is the caller graph for this function:
|
inline |
Definition at line 713 of file http.h.
References m_body.
Referenced by ns3::QKDKeyManagerSystemApplication::ProcessFillRequest(), ns3::QKDKeyManagerSystemApplication::ProcessFillResponse(), ns3::QKDApp004::ProcessGetKeyResponse(), ns3::QKDKeyManagerSystemApplication::ProcessKMSCloseRequest(), ns3::QKDKeyManagerSystemApplication::ProcessKMSCloseResponse(), ns3::QKDKeyManagerSystemApplication::ProcessNewAppRequest(), ns3::QKDKeyManagerSystemApplication::ProcessOpenConnectRequest(), ns3::QKDApp004::ProcessOpenConnectResponse(), ns3::QKDKeyManagerSystemApplication::ProcessRelayRequest(), ns3::QKDKeyManagerSystemApplication::ProcessRelayResponse(), ns3::QKDApp014::ProcessResponseFromKMS(), ns3::QKDApp014::ProcessSignalingPacketFromApp(), ns3::QKDKeyManagerSystemApplication::ProcessSKeyCreateRequest(), and ns3::QKDKeyManagerSystemApplication::ProcessSKeyCreateResponse().
Here is the caller graph for this function:
|
inline |
|
inline |
|
inline |
|
inline |
Definition at line 430 of file http.h.
References m_request_uri.
Referenced by ns3::QKDApp004::ProcessCloseResponse(), ns3::QKDKeyManagerSystemApplication::ProcessFillResponse(), ns3::QKDApp004::ProcessGetKeyResponse(), ns3::QKDKeyManagerSystemApplication::ProcessKMSCloseResponse(), ns3::QKDKeyManagerSystemApplication::ProcessNewAppResponse(), ns3::QKDApp004::ProcessOpenConnectResponse(), ns3::QKDKeyManagerSystemApplication::ProcessRegisterResponse(), ns3::QKDKeyManagerSystemApplication::ProcessRelayResponse(), ns3::QKDApp004::ProcessResponseFromKMS(), ns3::QKDApp014::ProcessResponseFromKMS(), ns3::QKDKeyManagerSystemApplication::ProcessResponseKMS(), ns3::QKDApp004::ProcessSignalingPacketFromApp(), and ns3::QKDKeyManagerSystemApplication::ProcessSKeyCreateResponse().
Here is the caller graph for this function:
|
inline |
Definition at line 685 of file http.h.
References GetContentLength(), and GetHeadersSize().
Here is the call graph for this function:
|
inline |
To be returned with a status code in a response is a status text describing the status code by text rather than by a code.
This method takes in one of those codes and tries to return a text for it.
Definition at line 168 of file http.h.
References Accepted, BadGateway, BadRequest, Conflict, Continue, Created, ExpectationFailed, Forbidden, Found, GatewayTimeout, Gone, HttpVersionNotSupported, ImaTeapot, InsufficientStorage, InternalServerError, LengthRequired, m_statusCode, MethodNotAllowed, MisdirectedRequest, MovedPermanently, MultipleChoice, NetworkAuthenticationRequired, NoContent, NonAuthoritativeInformation, NotAcceptable, NotExtended, NotFound, NotImplemented, NotModified, Ok, PartialContent, PayloadTooLarge, PaymentRequired, PermanentRedirect, PreconditionFailed, PreconditionRequired, ProxyAuthenticationRequired, RangeNotSatisfiable, RequestHeaderFieldsTooLarge, RequestTimeout, ResetContent, SeeOther, ServiceUnavailable, SwitchingProtocol, TemporaryRedirect, TooEarly, TooManyRequests, Unauthorized, UnavailableForLegalReasons, UnsupportedMediaType, UpgradeRequired, UriTooLong, and VariantAlsoNegotiates.
Referenced by ns3::QKDApp004::EstablishQueues(), ns3::QKDApp004::ProcessCloseResponse(), ns3::QKDKeyManagerSystemApplication::ProcessFillResponse(), ns3::QKDApp004::ProcessGetKeyResponse(), ns3::QKDKeyManagerSystemApplication::ProcessKMSCloseResponse(), ns3::QKDKeyManagerSystemApplication::ProcessNewAppResponse(), ns3::QKDApp004::ProcessOpenConnectResponse(), ns3::QKDKeyManagerSystemApplication::ProcessRegisterResponse(), ns3::QKDKeyManagerSystemApplication::ProcessRelayResponse(), ns3::QKDApp014::ProcessResponseFromKMS(), ns3::QKDApp014::ProcessSignalingPacketFromApp(), ns3::QKDApp004::ProcessSignalingPacketFromApp(), ns3::QKDKeyManagerSystemApplication::ProcessSKeyCreateResponse(), and ns3::QKDApp004::SendKsid().
Here is the caller graph for this function:
|
inline |
Get the status code for this message.
Definition at line 604 of file http.h.
References m_statusCode.
Referenced by ns3::HTTPMessageParser::Parse().
Here is the caller graph for this function:
|
inline |
Get the current status message for this message.
Returns an autogenerated status if one isn't specified.
Definition at line 622 of file http.h.
References m_statusMessage.
|
inline |
Grab the uri.
Definition at line 518 of file http.h.
References m_uri.
Referenced by ns3::QKDApp004::EstablishQueues(), ns3::QKDKeyManagerSystemApplication::ProcessGetKey004Request(), ns3::QKDKeyManagerSystemApplication::ProcessKMSCloseRequest(), ns3::QKDKeyManagerSystemApplication::ProcessNewAppRequest(), ns3::QKDKeyManagerSystemApplication::ProcessNewAppResponse(), ns3::QKDKeyManagerSystemApplication::ProcessPacketKMSs(), ns3::QKDKeyManagerSystemApplication::ProcessRegisterRequest(), ns3::QKDKeyManagerSystemApplication::ProcessRelayRequest(), ns3::QKDKeyManagerSystemApplication::ProcessRequestKMS(), ns3::QKDApp004::ProcessSignalingPacketFromApp(), ns3::QKDKeyManagerSystemApplication::ProcessSKeyCreateRequest(), and ns3::QKDApp004::SendKsid().
Here is the caller graph for this function:
|
inline |
|
inline |
|
inline |
Definition at line 846 of file http.h.
References m_fragmented.
|
inline |
Definition at line 841 of file http.h.
References m_fragmented, and ns3::value().
Referenced by ns3::HTTPMessageParser::Parse().
Here is the call graph for this function:
Here is the caller graph for this function:
|
inline |
Set a header in the map to the value provided.
Definition at line 409 of file http.h.
References m_contentLength, m_domain, m_headers, m_request_uri, m_uri, and ns3::value().
Referenced by ns3::QKDApp004::Close(), CreateRequest(), CreateResponse(), ns3::QKDApp004::EstablishQueues(), ns3::QKDApp004::GetKeyFromKMS(), ns3::QKDApp014::GetKeysFromKMS(), ns3::QKDApp014::GetKeyWithKeyIDs(), ns3::QKDApp014::GetStatusFromKMS(), ns3::QKDApp004::OpenConnect(), ns3::HTTPMessageParser::Parse(), ns3::QKDApp014::SendKeyIds(), and ns3::QKDApp004::SendKsid().
Here is the call graph for this function:
Here is the caller graph for this function:
|
inline |
Set a number of headers based on a generic map of keys and values.
Definition at line 437 of file http.h.
References m_headers.
Referenced by CreateResponse(), and CreateResponse().
Here is the caller graph for this function:Set the body of this message to a string value.
Definition at line 692 of file http.h.
References ns3::Create(), and SetMessageBody().
Referenced by CreateRequest(), CreateResponse(), and SetMessageBody().
Here is the call graph for this function:
Here is the caller graph for this function:Set the body of this message to an unsigned 8-bit binary value.
Definition at line 700 of file http.h.
References ns3::Create(), and m_body.
Here is the call graph for this function:Set the associated message method for this message.
Use NONE to switch this into a response.
Definition at line 463 of file http.h.
References DELETE, GET, HEAD, m_method, PATCH, POST, and PUT.
Referenced by CreateRequest(), CreateResponse(), and ns3::HTTPMessageParser::Parse().
Here is the caller graph for this function:Set the path of this message, which will be used if it is a request.
Definition at line 526 of file http.h.
References ns3::Create(), m_domain, m_path, m_scheme, and m_uri.
Referenced by CreateRequest(), and ns3::HTTPMessageParser::Parse().
Here is the call graph for this function:
Here is the caller graph for this function:
|
inline |
Set the status code of this HTTP message.
Definition at line 596 of file http.h.
References ns3::Create(), and m_statusCode.
Referenced by CreateResponse(), and ns3::HTTPMessageParser::Parse().
Here is the call graph for this function:
Here is the caller graph for this function:Set the status message of this HTTP message.
Definition at line 612 of file http.h.
References m_statusMessage.
Referenced by ns3::HTTPMessageParser::Parse().
Here is the caller graph for this function:Set the version of this HTTP message to the string specified.
Definition at line 580 of file http.h.
References m_version.
Referenced by ns3::HTTPMessageParser::Parse().
Here is the caller graph for this function:
|
inline |
To be returned with a status code in a response is a status text describing the status code by text rather than by a code.
This method takes in one of those codes and tries to return a text for it.
Definition at line 290 of file http.h.
References ns3::Create().
Referenced by ToString().
Here is the call graph for this function:
Here is the caller graph for this function:
|
inline |
Takes the headers added to the message along with the body and outputs it to a std::string for use in client/server HTTP messages.
Definition at line 632 of file http.h.
References ns3::CarriageReturn, ns3::Create(), GetMethodToString(), ns3::HTTPVersion11, m_body, m_contentLength, m_headers, m_headersLength, m_method, m_path, m_statusCode, m_statusMessage, NONE, and StatusTextFromStatusCode().
Referenced by ns3::QKDApp004::Close(), ns3::QKDApp004::EstablishQueues(), ns3::QKDKeyManagerSystemApplication::Fill(), GetHeadersSize(), ns3::QKDApp004::GetKeyFromKMS(), ns3::QKDApp014::GetKeysFromKMS(), ns3::QKDApp014::GetKeyWithKeyIDs(), ns3::QKDApp014::GetStatusFromKMS(), ns3::QKDKeyManagerSystemApplication::NewAppRequest(), ns3::QKDApp004::OpenConnect(), ns3::QKDKeyManagerSystemApplication::PacketReceivedKMSs(), ns3::QKDKeyManagerSystemApplication::ProcessCloseRequest(), ns3::QKDKeyManagerSystemApplication::ProcessGetKey004Request(), ns3::QKDKeyManagerSystemApplication::ProcessKMSCloseRequest(), ns3::QKDKeyManagerSystemApplication::ProcessNewAppRequest(), ns3::QKDKeyManagerSystemApplication::ProcessNewAppResponse(), ns3::QKDKeyManagerSystemApplication::ProcessRegisterRequest(), ns3::QKDKeyManagerSystemApplication::ProcessRelayRequest(), ns3::QKDKeyManagerSystemApplication::ProcessSKeyCreateRequest(), ns3::QKDKeyManagerSystemApplication::RegisterRequest(), ns3::QKDKeyManagerSystemApplication::Relay(), ns3::QKDApp014::SendKeyIds(), and ns3::QKDApp004::SendKsid().
Here is the call graph for this function:
Here is the caller graph for this function:
|
private |
A vector of unsigned 8-bit integers used to store message bodies.
Definition at line 901 of file http.h.
Referenced by GetMessageBody(), GetMessageBodyString(), SetMessageBody(), and ToString().
|
private |
Definition at line 908 of file http.h.
Referenced by GetContentLength(), SetHeader(), and ToString().
|
private |
Definition at line 881 of file http.h.
Referenced by CreateRequest(), SetHeader(), and SetPath().
|
private |
Whether the payload size is less then content-length.
Definition at line 906 of file http.h.
Referenced by IsFragmented(), and SetFragmented().
|
private |
An unordered_map of headers using a std::string for both the key and the value.
Definition at line 896 of file http.h.
Referenced by GetHeader(), HeaderCount(), SetHeader(), SetHeaders(), and ToString().
|
private |
Definition at line 909 of file http.h.
Referenced by GetHeadersSize(), and ToString().
|
private |
The HTTP method for this message.
Defaults to NONE denoting a response.
Definition at line 857 of file http.h.
Referenced by GetMethod(), GetMethodToString(), SetMethod(), and ToString().
|
private |
The path for the resource specified in the message.
Only used for a request.
Defaults to blank.
Definition at line 878 of file http.h.
Referenced by GetPath(), SetPath(), and ToString().
|
private |
Definition at line 883 of file http.h.
Referenced by GetRequestUri(), and SetHeader().
|
private |
|
private |
A status code for this message.
This is ignored if this is a request, as requests have no notion of statuses.
Definition at line 864 of file http.h.
Referenced by GetStatus(), GetStatusCode(), SetStatusCode(), and ToString().
|
private |
A status message to be associated with the status code for this message.
Keep blank to use an automatically generated status message.
Definition at line 871 of file http.h.
Referenced by GetStatusMessage(), SetStatusMessage(), and ToString().
|
private |
Definition at line 882 of file http.h.
Referenced by GetUri(), SetHeader(), and SetPath().
|
private |
The version used for this HTTP message as a string.
Defaults to "HTTP/1.1"
Definition at line 890 of file http.h.
Referenced by GetVersion(), and SetVersion().