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 (int nTimeout)
 
virtual QString ReadLine (int msecs)=0
 
virtual qint64 ReadBlock (char *pData, qint64 nMaxLen, int msecs=0)=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}
 
uint m_nKeepAliveTimeout {0}
 

Detailed Description

Definition at line 107 of file httprequest.h.

Constructor & Destructor Documentation

◆ HTTPRequest()

HTTPRequest::HTTPRequest ( )
inline

Definition at line 208 of file httprequest.h.

◆ ~HTTPRequest()

virtual HTTPRequest::~HTTPRequest ( )
virtualdefault

Member Function Documentation

◆ SetRequestType()

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

Definition at line 177 of file httprequest.cpp.

Referenced by ProcessRequestLine().

◆ SetRequestProtocol()

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

Definition at line 899 of file httprequest.cpp.

Referenced by ProcessRequestLine().

◆ SetContentType()

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

Definition at line 944 of file httprequest.cpp.

Referenced by ParseRequest().

◆ ProcessRequestLine()

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

Definition at line 1454 of file httprequest.cpp.

Referenced by ParseRequest().

◆ ProcessSOAPPayload()

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

Definition at line 1660 of file httprequest.cpp.

Referenced by ParseRequest().

◆ ExtractMethodFromURL()

void HTTPRequest::ExtractMethodFromURL ( )
protected

Definition at line 1629 of file httprequest.cpp.

Referenced by ParseRequest().

◆ GetResponseStatus()

QString HTTPRequest::GetResponseStatus ( void  ) const
protected

Definition at line 962 of file httprequest.cpp.

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

◆ GetResponseType()

QString HTTPRequest::GetResponseType ( void  ) const
protected

Definition at line 1025 of file httprequest.cpp.

Referenced by BuildResponseHeader().

◆ GetResponseHeaders()

QString HTTPRequest::GetResponseHeaders ( void  )
protected

Definition at line 1191 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 1525 of file httprequest.cpp.

Referenced by SendResponseFile().

◆ ParseKeepAlive()

bool HTTPRequest::ParseKeepAlive ( void  )
protected

Definition at line 1210 of file httprequest.cpp.

Referenced by ParseRequest().

◆ ParseCookies()

void HTTPRequest::ParseCookies ( void  )
protected

Definition at line 1244 of file httprequest.cpp.

Referenced by ParseRequest().

◆ BuildResponseHeader()

QString HTTPRequest::BuildResponseHeader ( long long  nSize)
protected

Definition at line 204 of file httprequest.cpp.

Referenced by SendResponse(), and SendResponseFile().

◆ SendData()

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

Definition at line 671 of file httprequest.cpp.

Referenced by SendFile(), and SendResponse().

◆ SendFile()

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

Definition at line 721 of file httprequest.cpp.

Referenced by SendResponseFile().

◆ IsProtected()

bool HTTPRequest::IsProtected ( ) const
inlineprotected

Definition at line 195 of file httprequest.h.

◆ IsEncrypted()

bool HTTPRequest::IsEncrypted ( ) const
inlineprotected

Definition at line 196 of file httprequest.h.

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

◆ Authenticated()

bool HTTPRequest::Authenticated ( )
protected

Definition at line 2137 of file httprequest.cpp.

Referenced by ParseRequest().

◆ GetAuthenticationHeader()

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

Definition at line 1875 of file httprequest.cpp.

Referenced by DigestAuthentication(), and ParseRequest().

◆ CalculateDigestNonce()

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

Definition at line 1905 of file httprequest.cpp.

Referenced by DigestAuthentication(), and GetAuthenticationHeader().

◆ BasicAuthentication()

bool HTTPRequest::BasicAuthentication ( )
protected

Definition at line 1917 of file httprequest.cpp.

Referenced by Authenticated().

◆ DigestAuthentication()

bool HTTPRequest::DigestAuthentication ( )
protected

Definition at line 1976 of file httprequest.cpp.

Referenced by Authenticated().

◆ AddCORSHeaders()

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

Definition at line 2280 of file httprequest.cpp.

Referenced by BuildResponseHeader().

◆ ParseRequest()

bool HTTPRequest::ParseRequest ( )

Definition at line 1262 of file httprequest.cpp.

Referenced by HttpWorker::run().

◆ FormatErrorResponse()

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

Definition at line 733 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 786 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 312 of file httprequest.cpp.

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

◆ SendResponseFile()

qint64 HTTPRequest::SendResponseFile ( const QString &  sFileName)

Definition at line 495 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 2173 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 235 of file httprequest.h.

Referenced by HttpWorker::run().

◆ GetSerializer()

Serializer * HTTPRequest::GetSerializer ( )

Definition at line 1768 of file httprequest.cpp.

Referenced by ServiceHost::FormatResponse().

◆ GetResponsePage()

QByteArray HTTPRequest::GetResponsePage ( void  )

◆ GetRequestProtocol()

QString HTTPRequest::GetRequestProtocol ( ) const

Definition at line 912 of file httprequest.cpp.

Referenced by ServerSideScripting::EvaluatePage().

◆ GetResponseProtocol()

QString HTTPRequest::GetResponseProtocol ( )
static

Definition at line 923 of file httprequest.cpp.

Referenced by BuildResponseHeader().

◆ GetRequestType()

QString HTTPRequest::GetRequestType ( ) const

Definition at line 2240 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 1064 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 1132 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 1829 of file httprequest.cpp.

◆ GetETagHash()

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

Definition at line 1845 of file httprequest.cpp.

◆ SetKeepAliveTimeout()

void HTTPRequest::SetKeepAliveTimeout ( int  nTimeout)
inline

Definition at line 255 of file httprequest.h.

Referenced by HttpWorker::run().

◆ IsUrlProtected()

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

Definition at line 1856 of file httprequest.cpp.

Referenced by ParseRequest().

◆ ReadLine()

virtual QString HTTPRequest::ReadLine ( int  msecs)
pure virtual

Implemented in BufferedSocketDeviceRequest.

Referenced by ParseRequest().

◆ ReadBlock()

virtual qint64 HTTPRequest::ReadBlock ( char *  pData,
qint64  nMaxLen,
int  msecs = 0 
)
pure virtual

Implemented in BufferedSocketDeviceRequest.

Referenced by ParseRequest().

◆ WriteBlock()

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

◆ GetHostName()

QString HTTPRequest::GetHostName ( void  )
virtual

Definition at line 2214 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 111 of file httprequest.h.

Referenced by GetResponseHeaders().

◆ m_procReqLineExp

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

Definition at line 113 of file httprequest.h.

Referenced by ProcessRequestLine().

◆ m_parseRangeExp

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

Definition at line 114 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 119 of file httprequest.h.

Referenced by ParseRequest(), and SetContentType().

◆ m_sRawRequest

QString HTTPRequest::m_sRawRequest

◆ m_sOriginalUrl

QString HTTPRequest::m_sOriginalUrl

Definition at line 123 of file httprequest.h.

Referenced by DigestAuthentication(), and ProcessRequestLine().

◆ m_sRequestUrl

QString HTTPRequest::m_sRequestUrl

Definition at line 124 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 131 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 135 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 139 of file httprequest.h.

Referenced by ParseRequest().

◆ m_bEncrypted

bool HTTPRequest::m_bEncrypted {false}

Definition at line 140 of file httprequest.h.

Referenced by HttpWorker::run().

◆ m_bSOAPRequest

bool HTTPRequest::m_bSOAPRequest {false}

◆ m_sNameSpace

QString HTTPRequest::m_sNameSpace

Definition at line 143 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 157 of file httprequest.h.

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

◆ m_sPrivateToken

QString HTTPRequest::m_sPrivateToken

Definition at line 159 of file httprequest.h.

Referenced by CalculateDigestNonce().

◆ m_userSession

MythUserSession HTTPRequest::m_userSession

◆ m_bKeepAlive

bool HTTPRequest::m_bKeepAlive {true}
private

Definition at line 164 of file httprequest.h.

Referenced by BuildResponseHeader(), and ParseRequest().

◆ m_nKeepAliveTimeout

uint HTTPRequest::m_nKeepAliveTimeout {0}
private

Definition at line 165 of file httprequest.h.

Referenced by BuildResponseHeader().


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