MythTV  master
Public Slots | Signals | Public Member Functions | Static Public Member Functions | Protected Slots | Private Member Functions | Private Attributes | List of all members
MythHTTPSocket Class Reference

#include <mythhttpsocket.h>

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

Public Slots

void PathsChanged (const QStringList &Paths)
 Update our list of recognised file paths. More...
 
void HandlersChanged (const HTTPHandlers &Handlers)
 
void ServicesChanged (const HTTPServices &Services)
 
void HostsChanged (const QStringList &Hosts)
 
void OriginsChanged (const QStringList &Origins)
 Update the list of allowed Origins. More...
 
void NewTextMessage (const StringPayload &Text)
 
void NewRawTextMessage (const DataPayloads &Payloads)
 
static void NewBinaryMessage (const DataPayloads &Payloads)
 

Signals

void Finish ()
 
void UpdateServices (const HTTPServices &Services)
 
void ThreadUpgraded (QThread *Thread)
 

Public Member Functions

 MythHTTPSocket (qintptr Socket, bool SSL, MythHTTPConfig Config)
 
 ~MythHTTPSocket () override
 
void Respond (const HTTPResponse &Response)
 Send response to client. More...
 

Static Public Member Functions

static void RespondDirect (qintptr Socket, const HTTPResponse &Response, const MythHTTPConfig &Config)
 Send an (error) response directly without creating a thread. More...
 

Protected Slots

void Disconnected ()
 The socket was disconnected. More...
 
void Timeout ()
 Close the socket after a period of inactivity. More...
 
void Read ()
 Read data from the socket which is parsed by MythHTTPParser. More...
 
void Stop ()
 Close the socket and quit the thread. More...
 
void Write (int64_t Written=0)
 
void Error (QAbstractSocket::SocketError Error)
 

Private Member Functions

void SetupWebSocket ()
 Transition socket to a WebSocket. More...
 

Private Attributes

qintptr m_socketFD { 0 }
 
MythHTTPConfig m_config
 
HTTPServicePtrs m_activeServices
 
bool m_stopping { false }
 
QTcpSocket * m_socket { nullptr }
 
MythWebSocketm_websocket { nullptr }
 
QString m_peer
 
QTimer m_timer
 
MythHTTPParser m_parser
 
HTTPQueue m_queue
 
int64_t m_totalToSend { 0 }
 
int64_t m_totalWritten { 0 }
 
int64_t m_totalSent { 0 }
 
QElapsedTimer m_writeTime
 
HTTPData m_writeBuffer { nullptr }
 
MythHTTPConnection m_nextConnection { HTTPConnectionClose }
 
MythSocketProtocol m_protocol { ProtHTTP }
 
bool m_testSocket { false }
 
MythWebSocketEventm_websocketevent { nullptr }
 

Detailed Description

Definition at line 18 of file mythhttpsocket.h.

Constructor & Destructor Documentation

◆ MythHTTPSocket()

MythHTTPSocket::MythHTTPSocket ( qintptr  Socket,
bool  SSL,
MythHTTPConfig  Config 
)
explicit

Definition at line 28 of file mythhttpsocket.cpp.

◆ ~MythHTTPSocket()

MythHTTPSocket::~MythHTTPSocket ( )
override

Definition at line 95 of file mythhttpsocket.cpp.

Member Function Documentation

◆ Finish

void MythHTTPSocket::Finish ( )
signal

◆ UpdateServices

void MythHTTPSocket::UpdateServices ( const HTTPServices Services)
signal

Referenced by MythHTTPSocket(), and ServicesChanged().

◆ ThreadUpgraded

void MythHTTPSocket::ThreadUpgraded ( QThread *  Thread)
signal

◆ PathsChanged

void MythHTTPSocket::PathsChanged ( const QStringList &  Paths)
slot

Update our list of recognised file paths.

The initial set of paths is passed in via the constructor. Any changes are notified using this slot.

Definition at line 109 of file mythhttpsocket.cpp.

Referenced by MythHTTPThread::run().

◆ HandlersChanged

void MythHTTPSocket::HandlersChanged ( const HTTPHandlers Handlers)
slot

Definition at line 114 of file mythhttpsocket.cpp.

Referenced by MythHTTPThread::run().

◆ ServicesChanged

void MythHTTPSocket::ServicesChanged ( const HTTPServices Services)
slot

Definition at line 119 of file mythhttpsocket.cpp.

Referenced by MythHTTPThread::run().

◆ HostsChanged

void MythHTTPSocket::HostsChanged ( const QStringList &  Hosts)
slot

Definition at line 135 of file mythhttpsocket.cpp.

Referenced by MythHTTPThread::run().

◆ OriginsChanged

void MythHTTPSocket::OriginsChanged ( const QStringList &  Origins)
slot

Update the list of allowed Origins.

The initial list is passed in via the constructor and any changes are notified via this slot.

Definition at line 130 of file mythhttpsocket.cpp.

Referenced by MythHTTPThread::run().

◆ NewTextMessage

void MythHTTPSocket::NewTextMessage ( const StringPayload Text)
slot

Definition at line 635 of file mythhttpsocket.cpp.

Referenced by SetupWebSocket().

◆ NewRawTextMessage

void MythHTTPSocket::NewRawTextMessage ( const DataPayloads Payloads)
slot

Definition at line 642 of file mythhttpsocket.cpp.

Referenced by SetupWebSocket().

◆ NewBinaryMessage

void MythHTTPSocket::NewBinaryMessage ( const DataPayloads Payloads)
staticslot

Definition at line 649 of file mythhttpsocket.cpp.

Referenced by SetupWebSocket().

◆ Respond()

void MythHTTPSocket::Respond ( const HTTPResponse Response)

Send response to client.

Queue headers, queue content, signal whether to close the socket and push first data to start the write.

Definition at line 358 of file mythhttpsocket.cpp.

Referenced by Read(), and Timeout().

◆ RespondDirect()

void MythHTTPSocket::RespondDirect ( qintptr  Socket,
const HTTPResponse Response,
const MythHTTPConfig Config 
)
static

Send an (error) response directly without creating a thread.

This is used to send 503 Service Unavailable

Definition at line 418 of file mythhttpsocket.cpp.

◆ Disconnected

void MythHTTPSocket::Disconnected ( )
protectedslot

The socket was disconnected.

The QTcpSocket::disconnected signal is also connected to our QThread::quit slot, so the thread will be closed once the socket is disconnected.

Definition at line 145 of file mythhttpsocket.cpp.

Referenced by MythHTTPSocket().

◆ Timeout

void MythHTTPSocket::Timeout ( )
protectedslot

Close the socket after a period of inactivity.

This ensures we recycle unused threads for new connections.

Definition at line 160 of file mythhttpsocket.cpp.

Referenced by MythHTTPSocket().

◆ Read

void MythHTTPSocket::Read ( )
protectedslot

Read data from the socket which is parsed by MythHTTPParser.

If a complete request is received, move on to ProcessRequest.

Definition at line 209 of file mythhttpsocket.cpp.

Referenced by MythHTTPSocket(), and SetupWebSocket().

◆ Stop

void MythHTTPSocket::Stop ( )
protectedslot

Close the socket and quit the thread.

This is triggered by the activity timeout, invalid requests, if signalled by the parent server (i.e. closing down) or when the connection is closed after a request.

Definition at line 189 of file mythhttpsocket.cpp.

Referenced by MythHTTPSocket(), Read(), SetupWebSocket(), Timeout(), and Write().

◆ Write

void MythHTTPSocket::Write ( int64_t  Written = 0)
protectedslot

Definition at line 433 of file mythhttpsocket.cpp.

Referenced by MythHTTPSocket(), Respond(), and SetupWebSocket().

◆ Error

void MythHTTPSocket::Error ( QAbstractSocket::SocketError  Error)
protectedslot

Definition at line 150 of file mythhttpsocket.cpp.

Referenced by MythHTTPSocket().

◆ SetupWebSocket()

void MythHTTPSocket::SetupWebSocket ( )
private

Transition socket to a WebSocket.

Definition at line 595 of file mythhttpsocket.cpp.

Referenced by Write().

Member Data Documentation

◆ m_socketFD

qintptr MythHTTPSocket::m_socketFD { 0 }
private

Definition at line 55 of file mythhttpsocket.h.

Referenced by MythHTTPSocket().

◆ m_config

MythHTTPConfig MythHTTPSocket::m_config
private

◆ m_activeServices

HTTPServicePtrs MythHTTPSocket::m_activeServices
private

Definition at line 57 of file mythhttpsocket.h.

Referenced by MythHTTPSocket(), and Read().

◆ m_stopping

bool MythHTTPSocket::m_stopping { false }
private

Definition at line 58 of file mythhttpsocket.h.

Referenced by Read(), Stop(), and Write().

◆ m_socket

QTcpSocket* MythHTTPSocket::m_socket { nullptr }
private

◆ m_websocket

MythWebSocket* MythHTTPSocket::m_websocket { nullptr }
private

Definition at line 60 of file mythhttpsocket.h.

Referenced by SetupWebSocket(), Stop(), and ~MythHTTPSocket().

◆ m_peer

QString MythHTTPSocket::m_peer
private

Definition at line 61 of file mythhttpsocket.h.

Referenced by MythHTTPSocket().

◆ m_timer

QTimer MythHTTPSocket::m_timer
private

Definition at line 62 of file mythhttpsocket.h.

Referenced by MythHTTPSocket(), Read(), SetupWebSocket(), Stop(), and Write().

◆ m_parser

MythHTTPParser MythHTTPSocket::m_parser
private

Definition at line 63 of file mythhttpsocket.h.

Referenced by Read().

◆ m_queue

HTTPQueue MythHTTPSocket::m_queue
private

Definition at line 64 of file mythhttpsocket.h.

Referenced by Read(), Respond(), Timeout(), and Write().

◆ m_totalToSend

int64_t MythHTTPSocket::m_totalToSend { 0 }
private

Definition at line 65 of file mythhttpsocket.h.

Referenced by Respond(), and Write().

◆ m_totalWritten

int64_t MythHTTPSocket::m_totalWritten { 0 }
private

Definition at line 66 of file mythhttpsocket.h.

Referenced by Respond(), and Write().

◆ m_totalSent

int64_t MythHTTPSocket::m_totalSent { 0 }
private

Definition at line 67 of file mythhttpsocket.h.

Referenced by Respond(), and Write().

◆ m_writeTime

QElapsedTimer MythHTTPSocket::m_writeTime
private

Definition at line 68 of file mythhttpsocket.h.

Referenced by Respond(), and Write().

◆ m_writeBuffer

HTTPData MythHTTPSocket::m_writeBuffer { nullptr }
private

Definition at line 69 of file mythhttpsocket.h.

Referenced by Respond(), and Write().

◆ m_nextConnection

MythHTTPConnection MythHTTPSocket::m_nextConnection { HTTPConnectionClose }
private

Definition at line 70 of file mythhttpsocket.h.

Referenced by Respond(), and Write().

◆ m_protocol

MythSocketProtocol MythHTTPSocket::m_protocol { ProtHTTP }
private

Definition at line 71 of file mythhttpsocket.h.

Referenced by Read(), and SetupWebSocket().

◆ m_testSocket

bool MythHTTPSocket::m_testSocket { false }
private

Definition at line 73 of file mythhttpsocket.h.

Referenced by Read(), and SetupWebSocket().

◆ m_websocketevent

MythWebSocketEvent* MythHTTPSocket::m_websocketevent { nullptr }
private

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