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, QString sDefault)
 
bool GetKeepAlive ()
 
SerializerGetSerializer ()
 
QByteArray GetResponsePage (void)
 
QString GetRequestProtocol () const
 
QString GetResponseProtocol () const
 
QString GetRequestType () const
 
void SetKeepAliveTimeout (int nTimeout)
 
bool IsUrlProtected (const QString &sBaseUrl)
 
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 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)
 

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
 
QStringMap 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)
 
QString GetResponseType (void)
 
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)
 
bool BasicAuthentication ()
 
bool DigestAuthentication ()
 
void AddCORSHeaders (const QString &sOrigin)
 

Protected Attributes

QRegExp m_procReqLineExp {"[ \r\n][ \r\n]*"}
 
QRegExp 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 105 of file httprequest.h.

Constructor & Destructor Documentation

◆ HTTPRequest()

HTTPRequest::HTTPRequest ( )
inline

Definition at line 206 of file httprequest.h.

◆ ~HTTPRequest()

virtual HTTPRequest::~HTTPRequest ( )
virtualdefault

Member Function Documentation

◆ SetRequestType()

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

Definition at line 163 of file httprequest.cpp.

◆ SetRequestProtocol()

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

Definition at line 881 of file httprequest.cpp.

◆ SetContentType()

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

Definition at line 926 of file httprequest.cpp.

◆ ProcessRequestLine()

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

Definition at line 1433 of file httprequest.cpp.

◆ ProcessSOAPPayload()

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

Definition at line 1629 of file httprequest.cpp.

◆ ExtractMethodFromURL()

void HTTPRequest::ExtractMethodFromURL ( )
protected

Definition at line 1601 of file httprequest.cpp.

◆ GetResponseStatus()

QString HTTPRequest::GetResponseStatus ( void  )
protected

Definition at line 944 of file httprequest.cpp.

◆ GetResponseType()

QString HTTPRequest::GetResponseType ( void  )
protected

Definition at line 1007 of file httprequest.cpp.

◆ GetResponseHeaders()

QString HTTPRequest::GetResponseHeaders ( void  )
protected

Definition at line 1170 of file httprequest.cpp.

◆ ParseRange()

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

Definition at line 1501 of file httprequest.cpp.

◆ ParseKeepAlive()

bool HTTPRequest::ParseKeepAlive ( void  )
protected

Definition at line 1189 of file httprequest.cpp.

◆ ParseCookies()

void HTTPRequest::ParseCookies ( void  )
protected

Definition at line 1223 of file httprequest.cpp.

◆ BuildResponseHeader()

QString HTTPRequest::BuildResponseHeader ( long long  nSize)
protected

Definition at line 190 of file httprequest.cpp.

◆ SendData()

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

Definition at line 648 of file httprequest.cpp.

◆ SendFile()

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

Definition at line 701 of file httprequest.cpp.

◆ IsProtected()

bool HTTPRequest::IsProtected ( ) const
inlineprotected

Definition at line 193 of file httprequest.h.

◆ IsEncrypted()

bool HTTPRequest::IsEncrypted ( ) const
inlineprotected

Definition at line 194 of file httprequest.h.

◆ Authenticated()

bool HTTPRequest::Authenticated ( )
protected

Definition at line 2100 of file httprequest.cpp.

◆ GetAuthenticationHeader()

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

Definition at line 1838 of file httprequest.cpp.

◆ CalculateDigestNonce()

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

Definition at line 1868 of file httprequest.cpp.

◆ BasicAuthentication()

bool HTTPRequest::BasicAuthentication ( )
protected

Definition at line 1880 of file httprequest.cpp.

◆ DigestAuthentication()

bool HTTPRequest::DigestAuthentication ( )
protected

Definition at line 1939 of file httprequest.cpp.

◆ AddCORSHeaders()

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

Definition at line 2243 of file httprequest.cpp.

◆ ParseRequest()

bool HTTPRequest::ParseRequest ( )

Definition at line 1241 of file httprequest.cpp.

Referenced by HttpWorker::run().

◆ FormatErrorResponse()

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

Definition at line 713 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 766 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 297 of file httprequest.cpp.

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

◆ SendResponseFile()

qint64 HTTPRequest::SendResponseFile ( const QString &  sFileName)

Definition at line 474 of file httprequest.cpp.

◆ 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 2136 of file httprequest.cpp.

◆ GetRequestHeader()

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

◆ GetKeepAlive()

bool HTTPRequest::GetKeepAlive ( )
inline

Definition at line 233 of file httprequest.h.

Referenced by HttpWorker::run().

◆ GetSerializer()

Serializer * HTTPRequest::GetSerializer ( )

Definition at line 1735 of file httprequest.cpp.

Referenced by ServiceHost::FormatResponse().

◆ GetResponsePage()

QByteArray HTTPRequest::GetResponsePage ( void  )

◆ GetRequestProtocol()

QString HTTPRequest::GetRequestProtocol ( ) const

Definition at line 894 of file httprequest.cpp.

Referenced by ServerSideScripting::EvaluatePage().

◆ GetResponseProtocol()

QString HTTPRequest::GetResponseProtocol ( ) const

Definition at line 905 of file httprequest.cpp.

◆ GetRequestType()

QString HTTPRequest::GetRequestType ( ) const

Definition at line 2203 of file httprequest.cpp.

Referenced by ServerSideScripting::EvaluatePage().

◆ GetMimeType()

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

◆ GetSupportedMimeTypes()

QStringList HTTPRequest::GetSupportedMimeTypes ( )
static

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

◆ Encode()

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

◆ Decode()

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

Definition at line 1792 of file httprequest.cpp.

◆ GetETagHash()

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

Definition at line 1808 of file httprequest.cpp.

◆ SetKeepAliveTimeout()

void HTTPRequest::SetKeepAliveTimeout ( int  nTimeout)
inline

Definition at line 252 of file httprequest.h.

Referenced by HttpWorker::run().

◆ IsUrlProtected()

bool HTTPRequest::IsUrlProtected ( const QString &  sBaseUrl)

Definition at line 1819 of file httprequest.cpp.

◆ ReadLine()

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

Implemented in BufferedSocketDeviceRequest.

◆ ReadBlock()

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

Implemented in BufferedSocketDeviceRequest.

◆ WriteBlock()

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

Implemented in BufferedSocketDeviceRequest.

◆ GetHostName()

QString HTTPRequest::GetHostName ( void  )
virtual

Definition at line 2177 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.

Member Data Documentation

◆ s_szServerHeaders

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

Definition at line 109 of file httprequest.h.

◆ m_procReqLineExp

QRegExp HTTPRequest::m_procReqLineExp {"[ \r\n][ \r\n]*"}
protected

Definition at line 111 of file httprequest.h.

◆ m_parseRangeExp

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

Definition at line 112 of file httprequest.h.

◆ m_eType

HttpRequestType HTTPRequest::m_eType {RequestTypeUnknown}

◆ m_eContentType

HttpContentType HTTPRequest::m_eContentType {ContentType_Unknown}

Definition at line 117 of file httprequest.h.

◆ m_sRawRequest

QString HTTPRequest::m_sRawRequest

◆ m_sOriginalUrl

QString HTTPRequest::m_sOriginalUrl

Definition at line 121 of file httprequest.h.

◆ m_sRequestUrl

QString HTTPRequest::m_sRequestUrl

Definition at line 122 of file httprequest.h.

Referenced by ServiceHost::ProcessRequest().

◆ 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

QStringMap HTTPRequest::m_mapHeaders

◆ m_mapCookies

QStringMap HTTPRequest::m_mapCookies

Definition at line 129 of file httprequest.h.

Referenced by ServerSideScripting::EvaluatePage().

◆ m_sPayload

QString HTTPRequest::m_sPayload

Definition at line 131 of file httprequest.h.

Referenced by UPNPSubscription::ProcessRequest().

◆ m_sProtocol

QString HTTPRequest::m_sProtocol

Definition at line 133 of file httprequest.h.

◆ m_nMajor

int HTTPRequest::m_nMajor {0}

Definition at line 134 of file httprequest.h.

◆ m_nMinor

int HTTPRequest::m_nMinor {0}

Definition at line 135 of file httprequest.h.

◆ m_bProtected

bool HTTPRequest::m_bProtected {false}

Definition at line 137 of file httprequest.h.

◆ m_bEncrypted

bool HTTPRequest::m_bEncrypted {false}

Definition at line 138 of file httprequest.h.

Referenced by HttpWorker::run().

◆ m_bSOAPRequest

bool HTTPRequest::m_bSOAPRequest {false}

Definition at line 140 of file httprequest.h.

Referenced by UPnp::FormatErrorResponse().

◆ m_sNameSpace

QString HTTPRequest::m_sNameSpace

Definition at line 141 of file httprequest.h.

◆ m_eResponseType

HttpResponseType HTTPRequest::m_eResponseType {ResponseTypeUnknown}

◆ m_sResponseTypeText

QString HTTPRequest::m_sResponseTypeText

Definition at line 146 of file httprequest.h.

Referenced by HttpConfig::ProcessRequest().

◆ 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 155 of file httprequest.h.

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

◆ m_sPrivateToken

QString HTTPRequest::m_sPrivateToken

Definition at line 157 of file httprequest.h.

◆ m_userSession

MythUserSession HTTPRequest::m_userSession

Definition at line 158 of file httprequest.h.

Referenced by ServerSideScripting::EvaluatePage().

◆ m_bKeepAlive

bool HTTPRequest::m_bKeepAlive {true}
private

Definition at line 162 of file httprequest.h.

◆ m_nKeepAliveTimeout

uint HTTPRequest::m_nKeepAliveTimeout {0}
private

Definition at line 163 of file httprequest.h.


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