Cuberite
A lightweight, fast and extensible game server for Minecraft
Classes | Public Types | Public Member Functions | Protected Attributes | Private Types | List of all members
cHTTPIncomingRequest Class Reference

Provides storage for an incoming HTTP request. More...

#include <HTTPMessage.h>

Inheritance diagram for cHTTPIncomingRequest:
Inheritance graph
[legend]
Collaboration diagram for cHTTPIncomingRequest:
Collaboration graph
[legend]

Classes

class  cUserData
 Base class for anything that can be used as the UserData for the request. More...
 

Public Types

using cUserDataPtr = std::shared_ptr< cUserData >
 
- Public Types inherited from cHTTPMessage
enum  eKind { mkRequest , mkResponse }
 
enum  eStatus { HTTP_OK = 200 , HTTP_BAD_REQUEST = 400 }
 

Public Member Functions

virtual void AddHeader (const AString &a_Key, const AString &a_Value) override
 Adds the specified header into the internal list of headers. More...
 
 cHTTPIncomingRequest (const AString &a_Method, const AString &a_URL)
 Creates a new instance of the class, containing the method and URL provided by the client. More...
 
bool DoesAllowKeepAlive (void) const
 
const AStringGetAuthPassword (void) const
 Returns the password that the request presented. More...
 
const AStringGetAuthUsername (void) const
 Returns the username that the request presented. More...
 
const AStringGetMethod (void) const
 Returns the method used in the request. More...
 
const AStringGetURL (void) const
 Returns the URL used in the request. More...
 
AString GetURLPath (void) const
 Returns the path part of the URL. More...
 
cUserDataPtr GetUserData (void)
 Returns the data attached to this request by the class client. More...
 
bool HasAuth (void) const
 Returns true if the request has had the Auth header present. More...
 
void SetUserData (cUserDataPtr a_UserData)
 Attaches any kind of data to this request, to be later retrieved by GetUserData(). More...
 
- Public Member Functions inherited from cHTTPMessage
 cHTTPMessage (eKind a_Kind)
 
size_t GetContentLength (void) const
 
const AStringGetContentType (void) const
 
void SetContentLength (size_t a_ContentLength)
 
void SetContentType (const AString &a_ContentType)
 
virtual ~cHTTPMessage ()
 

Protected Attributes

bool m_AllowKeepAlive
 Set to true if the request indicated that it supports keepalives. More...
 
AString m_AuthPassword
 The password used for auth. More...
 
AString m_AuthUsername
 The username used for auth. More...
 
bool m_HasAuth
 Set to true if the request contains auth data that was understood by the parser. More...
 
AString m_Method
 Method of the request (GET / PUT / POST / ...) More...
 
AString m_URL
 Full URL of the request. More...
 
cUserDataPtr m_UserData
 Any data attached to the request by the class client. More...
 
- Protected Attributes inherited from cHTTPMessage
size_t m_ContentLength
 Length of the content that is to be received. More...
 
AString m_ContentType
 Type of the content; parsed by AddHeader(), set directly by SetContentLength() More...
 
AStringMap m_Headers
 Map of headers, with their keys lowercased. More...
 
eKind m_Kind
 

Private Types

using Super = cHTTPMessage
 

Additional Inherited Members

- Protected Types inherited from cHTTPMessage
using cNameValueMap = std::map< AString, AString >
 

Detailed Description

Provides storage for an incoming HTTP request.

Definition at line 88 of file HTTPMessage.h.

Member Typedef Documentation

◆ cUserDataPtr

Definition at line 102 of file HTTPMessage.h.

◆ Super

Definition at line 91 of file HTTPMessage.h.

Constructor & Destructor Documentation

◆ cHTTPIncomingRequest()

cHTTPIncomingRequest::cHTTPIncomingRequest ( const AString a_Method,
const AString a_URL 
)

Creates a new instance of the class, containing the method and URL provided by the client.

Definition at line 107 of file HTTPMessage.cpp.

Member Function Documentation

◆ AddHeader()

void cHTTPIncomingRequest::AddHeader ( const AString a_Key,
const AString a_Value 
)
overridevirtual

Adds the specified header into the internal list of headers.

Overrides the parent to add recognizing additional headers: auth and keepalive.

Reimplemented from cHTTPMessage.

Definition at line 136 of file HTTPMessage.cpp.

◆ DoesAllowKeepAlive()

bool cHTTPIncomingRequest::DoesAllowKeepAlive ( void  ) const
inline

Definition at line 126 of file HTTPMessage.h.

◆ GetAuthPassword()

const AString& cHTTPIncomingRequest::GetAuthPassword ( void  ) const
inline

Returns the password that the request presented.

Only valid if HasAuth() is true

Definition at line 124 of file HTTPMessage.h.

◆ GetAuthUsername()

const AString& cHTTPIncomingRequest::GetAuthUsername ( void  ) const
inline

Returns the username that the request presented.

Only valid if HasAuth() is true

Definition at line 121 of file HTTPMessage.h.

◆ GetMethod()

const AString& cHTTPIncomingRequest::GetMethod ( void  ) const
inline

Returns the method used in the request.

Definition at line 109 of file HTTPMessage.h.

◆ GetURL()

const AString& cHTTPIncomingRequest::GetURL ( void  ) const
inline

Returns the URL used in the request.

Definition at line 112 of file HTTPMessage.h.

◆ GetURLPath()

AString cHTTPIncomingRequest::GetURLPath ( void  ) const

Returns the path part of the URL.

Definition at line 119 of file HTTPMessage.cpp.

◆ GetUserData()

cUserDataPtr cHTTPIncomingRequest::GetUserData ( void  )
inline

Returns the data attached to this request by the class client.

Definition at line 132 of file HTTPMessage.h.

◆ HasAuth()

bool cHTTPIncomingRequest::HasAuth ( void  ) const
inline

Returns true if the request has had the Auth header present.

Definition at line 118 of file HTTPMessage.h.

◆ SetUserData()

void cHTTPIncomingRequest::SetUserData ( cUserDataPtr  a_UserData)
inline

Attaches any kind of data to this request, to be later retrieved by GetUserData().

Definition at line 129 of file HTTPMessage.h.

Member Data Documentation

◆ m_AllowKeepAlive

bool cHTTPIncomingRequest::m_AllowKeepAlive
protected

Set to true if the request indicated that it supports keepalives.

If false, the server will close the connection once the request is finished

Definition at line 157 of file HTTPMessage.h.

◆ m_AuthPassword

AString cHTTPIncomingRequest::m_AuthPassword
protected

The password used for auth.

Definition at line 153 of file HTTPMessage.h.

◆ m_AuthUsername

AString cHTTPIncomingRequest::m_AuthUsername
protected

The username used for auth.

Definition at line 150 of file HTTPMessage.h.

◆ m_HasAuth

bool cHTTPIncomingRequest::m_HasAuth
protected

Set to true if the request contains auth data that was understood by the parser.

Definition at line 147 of file HTTPMessage.h.

◆ m_Method

AString cHTTPIncomingRequest::m_Method
protected

Method of the request (GET / PUT / POST / ...)

Definition at line 141 of file HTTPMessage.h.

◆ m_URL

AString cHTTPIncomingRequest::m_URL
protected

Full URL of the request.

Definition at line 144 of file HTTPMessage.h.

◆ m_UserData

cUserDataPtr cHTTPIncomingRequest::m_UserData
protected

Any data attached to the request by the class client.

Definition at line 160 of file HTTPMessage.h.


The documentation for this class was generated from the following files: