MythTV  master
Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | Static Protected Attributes | Private Attributes | List of all members
HTTPRequest Class Referenceabstract

#include <httprequest.h>

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

Public Member Functions

 HTTPRequest ()
 
virtual ~HTTPRequest ()=default
 
bool ParseRequest ()
 
void FormatErrorResponse (bool bServerError, const QString &sFaultString, const QString &sDetails)
 
void FormatActionResponse (Serializer *ser)
 
void FormatActionResponse (const NameValues &pArgs)
 
void FormatFileResponse (const QString &sFileName)
 
void FormatRawResponse (const QString &sXML)
 
qint64 SendResponse (void)
 
qint64 SendResponseFile (const QString &sFileName)
 
void SetResponseHeader (const QString &sKey, const QString &sValue, bool replace=false)
 
void SetCookie (const QString &sKey, const QString &sValue, const QDateTime &expiryDate, bool secure)
 
QString GetRequestHeader (const QString &sKey, const QString &sDefault)
 
bool GetKeepAlive () const
 
SerializerGetSerializer ()
 
QByteArray GetResponsePage (void)
 
QString GetRequestProtocol () const
 
QString GetRequestType () const
 
QString GetLastHeader (const QString &sType) const
 
void SetKeepAliveTimeout (std::chrono::seconds nTimeout)
 
virtual QString ReadLine (std::chrono::milliseconds msecs)=0
 
virtual qint64 ReadBlock (char *pData, qint64 nMaxLen, std::chrono::milliseconds msecs=0ms)=0
 
virtual qint64 WriteBlock (const char *pData, qint64 nLen)=0
 
virtual QString GetHostName ()
 
virtual QString GetHostAddress ()=0
 
virtual quint16 GetHostPort ()=0
 
virtual QString GetPeerAddress ()=0
 
virtual int getSocketHandle ()=0
 

Static Public Member Functions

static QString GetResponseProtocol ()
 
static QString GetMimeType (const QString &sFileExtension)
 
static QStringList GetSupportedMimeTypes ()
 
static QString TestMimeType (const QString &sFileName)
 
static long GetParameters (QString sParams, QStringMap &mapParams)
 
static QString Encode (const QString &sIn)
 
static QString Decode (const QString &sIn)
 
static QString GetETagHash (const QByteArray &data)
 
static bool IsUrlProtected (const QString &sBaseUrl)
 

Public Attributes

HttpRequestType m_eType {RequestTypeUnknown}
 
HttpContentType m_eContentType {ContentType_Unknown}
 
QString m_sRawRequest
 
QString m_sOriginalUrl
 
QString m_sRequestUrl
 
QString m_sBaseUrl
 
QString m_sResourceUrl
 
QString m_sMethod
 
QStringMap m_mapParams
 
QStringMultiMap m_mapHeaders
 
QStringMap m_mapCookies
 
QString m_sPayload
 
QString m_sProtocol
 
int m_nMajor {0}
 
int m_nMinor {0}
 
bool m_bProtected {false}
 
bool m_bEncrypted {false}
 
bool m_bSOAPRequest {false}
 
QString m_sNameSpace
 
HttpResponseType m_eResponseType {ResponseTypeUnknown}
 
QString m_sResponseTypeText
 
long m_nResponseStatus {200}
 
QStringMap m_mapRespHeaders
 
QString m_sFileName
 
QBuffer m_response
 
IPostProcessm_pPostProcess {nullptr}
 
QString m_sPrivateToken
 
MythUserSession m_userSession
 

Protected Member Functions

HttpRequestType SetRequestType (const QString &sType)
 
void SetRequestProtocol (const QString &sLine)
 
HttpContentType SetContentType (const QString &sType)
 
void ProcessRequestLine (const QString &sLine)
 
bool ProcessSOAPPayload (const QString &sSOAPAction)
 
void ExtractMethodFromURL ()
 
QString GetResponseStatus (void) const
 
QString GetResponseType (void) const
 
QString GetResponseHeaders (void)
 
bool ParseRange (QString sRange, long long llSize, long long *pllStart, long long *pllEnd)
 
bool ParseKeepAlive (void)
 
void ParseCookies (void)
 
QString BuildResponseHeader (long long nSize)
 
qint64 SendData (QIODevice *pDevice, qint64 llStart, qint64 llBytes)
 
qint64 SendFile (QFile &file, qint64 llStart, qint64 llBytes)
 
bool IsProtected () const
 
bool IsEncrypted () const
 
bool Authenticated ()
 
QString GetAuthenticationHeader (bool isStale=false)
 
QString CalculateDigestNonce (const QString &timeStamp) const
 
bool BasicAuthentication ()
 
bool DigestAuthentication ()
 
void AddCORSHeaders (const QString &sOrigin)
 

Protected Attributes

QRegularExpression m_procReqLineExp {"\\s+"}
 
QRegularExpression m_parseRangeExp {"(\\d|\\-)"}
 

Static Protected Attributes

static const char * s_szServerHeaders = "Accept-Ranges: bytes\r\n"
 

Private Attributes

bool m_bKeepAlive {true}
 
std::chrono::seconds m_nKeepAliveTimeout {0s}
 

Detailed Description

Definition at line 109 of file httprequest.h.

Constructor & Destructor Documentation

◆ HTTPRequest()

HTTPRequest::HTTPRequest ( )
inline

Definition at line 210 of file httprequest.h.

◆ ~HTTPRequest()

virtual HTTPRequest::~HTTPRequest ( )
virtualdefault

Member Function Documentation

◆ SetRequestType()

HttpRequestType HTTPRequest::SetRequestType ( const QString &  sType)
protected

Definition at line 166 of file httprequest.cpp.

Referenced by ProcessRequestLine().

◆ SetRequestProtocol()

void HTTPRequest::SetRequestProtocol ( const QString &  sLine)
protected

Definition at line 828 of file httprequest.cpp.

Referenced by ProcessRequestLine().

◆ SetContentType()

HttpContentType HTTPRequest::SetContentType ( const QString &  sType)
protected

Definition at line 873 of file httprequest.cpp.

Referenced by ParseRequest().

◆ ProcessRequestLine()

void HTTPRequest::ProcessRequestLine ( const QString &  sLine)
protected

Definition at line 1382 of file httprequest.cpp.

Referenced by ParseRequest().

◆ ProcessSOAPPayload()

bool HTTPRequest::ProcessSOAPPayload ( const QString &  sSOAPAction)
protected

Definition at line 1574 of file httprequest.cpp.

Referenced by ParseRequest().

◆ ExtractMethodFromURL()

void HTTPRequest::ExtractMethodFromURL ( )
protected

Definition at line 1548 of file httprequest.cpp.

Referenced by ParseRequest().

◆ GetResponseStatus()

QString HTTPRequest::GetResponseStatus ( void  ) const
protected

Definition at line 895 of file httprequest.cpp.

Referenced by BuildResponseHeader(), GetResponsePage(), and SendResponse().

◆ GetResponseType()

QString HTTPRequest::GetResponseType ( void  ) const
protected

Definition at line 958 of file httprequest.cpp.

Referenced by BuildResponseHeader().

◆ GetResponseHeaders()

QString HTTPRequest::GetResponseHeaders ( void  )
protected

Definition at line 1119 of file httprequest.cpp.

Referenced by BuildResponseHeader().

◆ ParseRange()

bool HTTPRequest::ParseRange ( QString  sRange,
long long  llSize,
long long *  pllStart,
long long *  pllEnd 
)
protected

Definition at line 1449 of file httprequest.cpp.

Referenced by SendResponseFile().

◆ ParseKeepAlive()

bool HTTPRequest::ParseKeepAlive ( void  )
protected

Definition at line 1138 of file httprequest.cpp.

Referenced by ParseRequest().

◆ ParseCookies()

void HTTPRequest::ParseCookies ( void  )
protected

Definition at line 1172 of file httprequest.cpp.

Referenced by ParseRequest().

◆ BuildResponseHeader()

QString HTTPRequest::BuildResponseHeader ( long long  nSize)
protected

Definition at line 193 of file httprequest.cpp.

Referenced by SendResponse(), and SendResponseFile().

◆ SendData()

qint64 HTTPRequest::SendData ( QIODevice *  pDevice,
qint64  llStart,
qint64  llBytes 
)
protected

Definition at line 598 of file httprequest.cpp.

Referenced by SendFile(), and SendResponse().

◆ SendFile()

qint64 HTTPRequest::SendFile ( QFile &  file,
qint64  llStart,
qint64  llBytes 
)
protected

Definition at line 648 of file httprequest.cpp.

Referenced by SendResponseFile().

◆ IsProtected()

bool HTTPRequest::IsProtected ( ) const
inlineprotected

Definition at line 197 of file httprequest.h.

◆ IsEncrypted()

bool HTTPRequest::IsEncrypted ( ) const
inlineprotected

Definition at line 198 of file httprequest.h.

Referenced by BasicAuthentication(), DigestAuthentication(), and SetCookie().

◆ Authenticated()

bool HTTPRequest::Authenticated ( )
protected

Definition at line 2050 of file httprequest.cpp.

Referenced by ParseRequest().

◆ GetAuthenticationHeader()

QString HTTPRequest::GetAuthenticationHeader ( bool  isStale = false)
protected

Definition at line 1789 of file httprequest.cpp.

Referenced by DigestAuthentication(), and ParseRequest().

◆ CalculateDigestNonce()

QString HTTPRequest::CalculateDigestNonce ( const QString &  timeStamp) const
protected

Definition at line 1819 of file httprequest.cpp.

Referenced by DigestAuthentication(), and GetAuthenticationHeader().

◆ BasicAuthentication()

bool HTTPRequest::BasicAuthentication ( )
protected

Definition at line 1831 of file httprequest.cpp.

Referenced by Authenticated().

◆ DigestAuthentication()

bool HTTPRequest::DigestAuthentication ( )
protected

Definition at line 1890 of file httprequest.cpp.

Referenced by Authenticated().

◆ AddCORSHeaders()

void HTTPRequest::AddCORSHeaders ( const QString &  sOrigin)
protected

Definition at line 2193 of file httprequest.cpp.

Referenced by BuildResponseHeader().

◆ ParseRequest()

bool HTTPRequest::ParseRequest ( )

Definition at line 1190 of file httprequest.cpp.

Referenced by HttpWorker::run().

◆ FormatErrorResponse()

void HTTPRequest::FormatErrorResponse ( bool  bServerError,
const QString &  sFaultString,
const QString &  sDetails 
)

Definition at line 660 of file httprequest.cpp.

Referenced by UPnp::FormatErrorResponse().

◆ FormatActionResponse() [1/2]

void HTTPRequest::FormatActionResponse ( Serializer ser)

◆ FormatActionResponse() [2/2]

void HTTPRequest::FormatActionResponse ( const NameValues pArgs)

Definition at line 715 of file httprequest.cpp.

◆ FormatFileResponse()

void HTTPRequest::FormatFileResponse ( const QString &  sFileName)

◆ FormatRawResponse()

void HTTPRequest::FormatRawResponse ( const QString &  sXML)

◆ SendResponse()

qint64 HTTPRequest::SendResponse ( void  )

Definition at line 301 of file httprequest.cpp.

Referenced by UPnp::FormatRedirectResponse(), and HttpWorker::run().

◆ SendResponseFile()

qint64 HTTPRequest::SendResponseFile ( const QString &  sFileName)

Definition at line 453 of file httprequest.cpp.

Referenced by SendResponse().

◆ SetResponseHeader()

void HTTPRequest::SetResponseHeader ( const QString &  sKey,
const QString &  sValue,
bool  replace = false 
)

◆ SetCookie()

void HTTPRequest::SetCookie ( const QString &  sKey,
const QString &  sValue,
const QDateTime &  expiryDate,
bool  secure 
)

Definition at line 2086 of file httprequest.cpp.

Referenced by BasicAuthentication(), DigestAuthentication(), and ParseRequest().

◆ GetRequestHeader()

QString HTTPRequest::GetRequestHeader ( const QString &  sKey,
const QString &  sDefault 
)

◆ GetKeepAlive()

bool HTTPRequest::GetKeepAlive ( ) const
inline

Definition at line 237 of file httprequest.h.

Referenced by HttpWorker::run().

◆ GetSerializer()

Serializer * HTTPRequest::GetSerializer ( )

Definition at line 1682 of file httprequest.cpp.

Referenced by ServiceHost::FormatResponse().

◆ GetResponsePage()

QByteArray HTTPRequest::GetResponsePage ( void  )

◆ GetRequestProtocol()

QString HTTPRequest::GetRequestProtocol ( ) const

Definition at line 841 of file httprequest.cpp.

Referenced by ServerSideScripting::EvaluatePage().

◆ GetResponseProtocol()

QString HTTPRequest::GetResponseProtocol ( )
static

Definition at line 852 of file httprequest.cpp.

Referenced by BuildResponseHeader().

◆ GetRequestType()

QString HTTPRequest::GetRequestType ( ) const

Definition at line 2153 of file httprequest.cpp.

Referenced by DigestAuthentication(), and ServerSideScripting::EvaluatePage().

◆ GetLastHeader()

QString HTTPRequest::GetLastHeader ( const QString &  sType) const

◆ GetMimeType()

QString HTTPRequest::GetMimeType ( const QString &  sFileExtension)
static

◆ GetSupportedMimeTypes()

QStringList HTTPRequest::GetSupportedMimeTypes ( )
static

Definition at line 997 of file httprequest.cpp.

Referenced by GetSinkProtocolInfos(), and GetSourceProtocolInfos().

◆ TestMimeType()

QString HTTPRequest::TestMimeType ( const QString &  sFileName)
static

◆ GetParameters()

long HTTPRequest::GetParameters ( QString  sParams,
QStringMap mapParams 
)
static

Definition at line 1065 of file httprequest.cpp.

Referenced by ParseRequest(), and ProcessRequestLine().

◆ Encode()

QString HTTPRequest::Encode ( const QString &  sIn)
static

◆ Decode()

QString HTTPRequest::Decode ( const QString &  sIn)
static

Definition at line 1743 of file httprequest.cpp.

◆ GetETagHash()

QString HTTPRequest::GetETagHash ( const QByteArray &  data)
static

Definition at line 1759 of file httprequest.cpp.

◆ SetKeepAliveTimeout()

void HTTPRequest::SetKeepAliveTimeout ( std::chrono::seconds  nTimeout)
inline

Definition at line 257 of file httprequest.h.

Referenced by HttpWorker::run().

◆ IsUrlProtected()

bool HTTPRequest::IsUrlProtected ( const QString &  sBaseUrl)
static

Definition at line 1770 of file httprequest.cpp.

Referenced by ParseRequest().

◆ ReadLine()

virtual QString HTTPRequest::ReadLine ( std::chrono::milliseconds  msecs)
pure virtual

Implemented in BufferedSocketDeviceRequest.

Referenced by ParseRequest().

◆ ReadBlock()

virtual qint64 HTTPRequest::ReadBlock ( char *  pData,
qint64  nMaxLen,
std::chrono::milliseconds  msecs = 0ms 
)
pure virtual

Implemented in BufferedSocketDeviceRequest.

Referenced by ParseRequest().

◆ WriteBlock()

virtual qint64 HTTPRequest::WriteBlock ( const char *  pData,
qint64  nLen 
)
pure virtual

◆ GetHostName()

QString HTTPRequest::GetHostName ( )
virtual

Definition at line 2127 of file httprequest.cpp.

Referenced by ServerSideScripting::EvaluatePage().

◆ GetHostAddress()

virtual QString HTTPRequest::GetHostAddress ( )
pure virtual

◆ GetHostPort()

virtual quint16 HTTPRequest::GetHostPort ( )
pure virtual

◆ GetPeerAddress()

virtual QString HTTPRequest::GetPeerAddress ( )
pure virtual

◆ getSocketHandle()

virtual int HTTPRequest::getSocketHandle ( )
pure virtual

Implemented in BufferedSocketDeviceRequest.

Referenced by ParseRange(), and ParseRequest().

Member Data Documentation

◆ s_szServerHeaders

const char * HTTPRequest::s_szServerHeaders = "Accept-Ranges: bytes\r\n"
staticprotected

Definition at line 113 of file httprequest.h.

Referenced by GetResponseHeaders().

◆ m_procReqLineExp

QRegularExpression HTTPRequest::m_procReqLineExp {"\\s+"}
protected

Definition at line 115 of file httprequest.h.

Referenced by ProcessRequestLine().

◆ m_parseRangeExp

QRegularExpression HTTPRequest::m_parseRangeExp {"(\\d|\\-)"}
protected

Definition at line 116 of file httprequest.h.

Referenced by ParseRange().

◆ m_eType

HttpRequestType HTTPRequest::m_eType {RequestTypeUnknown}

◆ m_eContentType

HttpContentType HTTPRequest::m_eContentType {ContentType_Unknown}

Definition at line 121 of file httprequest.h.

Referenced by ParseRequest(), and SetContentType().

◆ m_sRawRequest

QString HTTPRequest::m_sRawRequest

◆ m_sOriginalUrl

QString HTTPRequest::m_sOriginalUrl

Definition at line 125 of file httprequest.h.

Referenced by DigestAuthentication(), and ProcessRequestLine().

◆ m_sRequestUrl

QString HTTPRequest::m_sRequestUrl

Definition at line 126 of file httprequest.h.

Referenced by ServiceHost::ProcessRequest(), and ProcessRequestLine().

◆ m_sBaseUrl

QString HTTPRequest::m_sBaseUrl

◆ m_sResourceUrl

QString HTTPRequest::m_sResourceUrl

◆ m_sMethod

QString HTTPRequest::m_sMethod

◆ m_mapParams

QStringMap HTTPRequest::m_mapParams

◆ m_mapHeaders

QStringMultiMap HTTPRequest::m_mapHeaders

◆ m_mapCookies

QStringMap HTTPRequest::m_mapCookies

Definition at line 133 of file httprequest.h.

Referenced by ServerSideScripting::EvaluatePage(), ParseCookies(), and ParseRequest().

◆ m_sPayload

QString HTTPRequest::m_sPayload

◆ m_sProtocol

QString HTTPRequest::m_sProtocol

Definition at line 137 of file httprequest.h.

Referenced by GetRequestProtocol(), and SetRequestProtocol().

◆ m_nMajor

int HTTPRequest::m_nMajor {0}

◆ m_nMinor

int HTTPRequest::m_nMinor {0}

◆ m_bProtected

bool HTTPRequest::m_bProtected {false}

Definition at line 141 of file httprequest.h.

Referenced by ParseRequest().

◆ m_bEncrypted

bool HTTPRequest::m_bEncrypted {false}

Definition at line 142 of file httprequest.h.

Referenced by HttpWorker::run().

◆ m_bSOAPRequest

bool HTTPRequest::m_bSOAPRequest {false}

◆ m_sNameSpace

QString HTTPRequest::m_sNameSpace

Definition at line 145 of file httprequest.h.

Referenced by FormatActionResponse(), GetSerializer(), and ProcessSOAPPayload().

◆ m_eResponseType

HttpResponseType HTTPRequest::m_eResponseType {ResponseTypeUnknown}

◆ m_sResponseTypeText

QString HTTPRequest::m_sResponseTypeText

◆ m_nResponseStatus

long HTTPRequest::m_nResponseStatus {200}

◆ m_mapRespHeaders

QStringMap HTTPRequest::m_mapRespHeaders

◆ m_sFileName

QString HTTPRequest::m_sFileName

◆ m_response

QBuffer HTTPRequest::m_response

◆ m_pPostProcess

IPostProcess* HTTPRequest::m_pPostProcess {nullptr}

Definition at line 159 of file httprequest.h.

Referenced by Eventing::HandleSubscribe(), and HttpWorker::run().

◆ m_sPrivateToken

QString HTTPRequest::m_sPrivateToken

Definition at line 161 of file httprequest.h.

Referenced by CalculateDigestNonce().

◆ m_userSession

MythUserSession HTTPRequest::m_userSession

◆ m_bKeepAlive

bool HTTPRequest::m_bKeepAlive {true}
private

Definition at line 166 of file httprequest.h.

Referenced by BuildResponseHeader(), and ParseRequest().

◆ m_nKeepAliveTimeout

std::chrono::seconds HTTPRequest::m_nKeepAliveTimeout {0s}
private

Definition at line 167 of file httprequest.h.

Referenced by BuildResponseHeader().


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