cutelyst 5.1.0
A C++ Web Framework built on top of Qt, using the simple approach of Catalyst (Perl) framework.
Cutelyst::ProtoRequestHttp Class Referencefinal
Inheritance diagram for Cutelyst::ProtoRequestHttp:
[legend]

Public Types

enum class  ChunkPhase {
  NotChunked , Size , Data , DataCrLf ,
  Trailers
}
 
enum  OpCode {
  OpCodeContinue , OpCodeText , OpCodeBinary , OpCodeReserved3 ,
  OpCodeReserved4 , OpCodeReserved5 , OpCodeReserved6 , OpCodeReserved7 ,
  OpCodeClose , OpCodePing , OpCodePong , OpCodeReservedB ,
  OpCodeReservedC , OpCodeReservedD , OpCodeReservedE , OpCodeReservedF
}
 
enum class  WebSocketPhase { WebSocketPhaseHeaders , WebSocketPhaseSize , WebSocketPhaseMask , WebSocketPhasePayload }
 
- Public Types inherited from Cutelyst::ProtocolData
enum class  HeaderConnection { NotSet , Keep , Close , Upgrade }
 
enum  ParserState { MethodLine , HeaderLine , ContentBody , H2Frames }
 
- Public Types inherited from Cutelyst::EngineRequest
enum  StatusFlag : quint8 {
  InitialState , FinalizedHeaders , IOWrite , Chunked ,
  ChunkedDone , Async , Finalized
}
 

Public Member Functions

 ProtoRequestHttp (Socket *sock, int bufferSize)
 
qint64 doWrite (const char *data, qint64 len) override final
 
qint64 doWrite (const QByteArray &data)
 
void processingFinished () override final
 
void resetData () override final
 
void setupNewConnection (Socket *sock) override final
 
virtual void socketDisconnected () override final
 
bool webSocketClose (quint16 code, const QString &reason) override final
 
bool webSocketSendBinaryMessage (const QByteArray &message) override final
 
bool webSocketSendPing (const QByteArray &payload) override final
 
bool webSocketSendTextMessage (const QString &message) override final
 
bool writeHeaders (quint16 status, const Cutelyst::Headers &headers) override final
 
- Public Member Functions inherited from Cutelyst::ProtocolData
 ProtocolData (const ProtocolData &)=delete
 
 ProtocolData (Socket *sock, int bufferSize)
 
ProtocolData & operator= (const ProtocolData &)=delete
 
- Public Member Functions inherited from Cutelyst::EngineRequest
void finalize ()
 
virtual void finalizeBody ()
 
virtual void finalizeCookies ()
 
virtual void finalizeError ()
 
virtual bool finalizeHeaders ()
 
void setPath (char *rawPath, int len)
 
void setPath (QByteArray &path)
 
bool webSocketHandshake (const QByteArray &key, const QByteArray &origin, const QByteArray &protocol)
 
qint64 write (const char *data, qint64 len)
 

Public Attributes

int beginLine
 
qint64 chunkBytesLeft
 
ChunkPhase chunkPhase
 
int last
 
quint8 websocket_continue_opcode
 
quint8 websocket_finn_opcode
 
quint32 websocket_mask
 
QByteArray websocket_message
 
quint32 websocket_need
 
QByteArray websocket_payload
 
quint64 websocket_payload_size
 
WebSocketPhase websocket_phase
 
int websocket_start_of_frame
 
bool websocketUpgraded
 
- Public Attributes inherited from Cutelyst::ProtocolData
int buf_size
 
char * buffer
 
ParserState connState
 
qint64 contentLength
 
HeaderConnection headerConnection
 
bool headerHost
 
QIODevice * io
 
Socket * sock
 
ProtocolData * upgradedFrom
 
bool X_Forwarded_For
 
bool X_Forwarded_Host
 
bool X_Forwarded_Proto
 
- Public Attributes inherited from Cutelyst::EngineRequest
QIODevice * body
 
Context * context
 
Headers headers
 
bool isSecure
 
QByteArray method
 
QString path
 
QByteArray protocol
 
QByteArray query
 
QHostAddress remoteAddress
 
quint16 remotePort
 
QString remoteUser
 
QByteArray serverAddress
 
TimePointSteady startOfRequest
 
Status status
 

Protected Member Functions

bool webSocketHandshakeDo (const QByteArray &key, const QByteArray &origin, const QByteArray &protocol) override final
 

Detailed Description

Definition at line 18 of file protocolhttp.h.

Member Enumeration Documentation

◆ ChunkPhase

enum class Cutelyst::ProtoRequestHttp::ChunkPhase
strong

Definition at line 52 of file protocolhttp.h.

◆ OpCode

enum Cutelyst::ProtoRequestHttp::OpCode

Definition at line 32 of file protocolhttp.h.

◆ WebSocketPhase

enum class Cutelyst::ProtoRequestHttp::WebSocketPhase
strong

Definition at line 24 of file protocolhttp.h.

Constructor & Destructor Documentation

◆ ProtoRequestHttp()

ProtoRequestHttp::ProtoRequestHttp ( Socket *  sock,
int  bufferSize 
)

Definition at line 494 of file protocolhttp.cpp.

◆ ~ProtoRequestHttp()

ProtoRequestHttp::~ProtoRequestHttp ( )
override

Definition at line 500 of file protocolhttp.cpp.

Member Function Documentation

◆ doWrite() [1/2]

qint64 ProtoRequestHttp::doWrite ( const char *  data,
qint64  len 
)
finaloverridevirtual

Reimplement this to do the RAW writing to the client

Implements Cutelyst::EngineRequest.

Definition at line 565 of file protocolhttp.cpp.

References QIODevice::write().

◆ doWrite() [2/2]

qint64 Cutelyst::ProtoRequestHttp::doWrite ( const QByteArray &  data)
inline

Definition at line 69 of file protocolhttp.h.

◆ processingFinished()

void ProtoRequestHttp::processingFinished ( )
finaloverridevirtual

This is called when the Application chain is finished processing this request, here the request can send final bytes to the client or do a clean up.

Default implementation deletes both body and context.

If a WebSocket upgrade was made then you will want to keep the context object around.

Reimplemented from Cutelyst::EngineRequest.

Definition at line 570 of file protocolhttp.cpp.

References Cutelyst::EngineRequest::status.

◆ resetData()

void Cutelyst::ProtoRequestHttp::resetData ( )
inlinefinaloverridevirtual

Reimplemented from Cutelyst::ProtocolData.

Definition at line 81 of file protocolhttp.h.

◆ setupNewConnection()

void ProtoRequestHttp::setupNewConnection ( Socket *  sock)
finaloverridevirtual

Implements Cutelyst::ProtocolData.

Definition at line 504 of file protocolhttp.cpp.

◆ socketDisconnected()

void ProtoRequestHttp::socketDisconnected ( )
finaloverridevirtual

Reimplemented from Cutelyst::ProtocolData.

Definition at line 663 of file protocolhttp.cpp.

◆ webSocketClose()

bool ProtoRequestHttp::webSocketClose ( quint16  code,
const QString &  reason 
)
finaloverridevirtual

Reimplemented from Cutelyst::EngineRequest.

Definition at line 648 of file protocolhttp.cpp.

◆ webSocketHandshakeDo()

bool ProtoRequestHttp::webSocketHandshakeDo ( const QByteArray &  key,
const QByteArray &  origin,
const QByteArray &  protocol 
)
finaloverrideprotectedvirtual

Reimplemented from Cutelyst::EngineRequest.

Definition at line 673 of file protocolhttp.cpp.

◆ webSocketSendBinaryMessage()

bool ProtoRequestHttp::webSocketSendBinaryMessage ( const QByteArray &  message)
finaloverridevirtual

Reimplemented from Cutelyst::EngineRequest.

Definition at line 620 of file protocolhttp.cpp.

◆ webSocketSendPing()

bool ProtoRequestHttp::webSocketSendPing ( const QByteArray &  payload)
finaloverridevirtual

Reimplemented from Cutelyst::EngineRequest.

Definition at line 634 of file protocolhttp.cpp.

◆ webSocketSendTextMessage()

bool ProtoRequestHttp::webSocketSendTextMessage ( const QString &  message)
finaloverridevirtual

Reimplemented from Cutelyst::EngineRequest.

Definition at line 605 of file protocolhttp.cpp.

◆ writeHeaders()

bool ProtoRequestHttp::writeHeaders ( quint16  status,
const Cutelyst::Headers &  headers 
)
finaloverridevirtual

Member Data Documentation

◆ beginLine

int Cutelyst::ProtoRequestHttp::beginLine

Definition at line 117 of file protocolhttp.h.

◆ chunkBytesLeft

qint64 Cutelyst::ProtoRequestHttp::chunkBytesLeft

Definition at line 121 of file protocolhttp.h.

◆ chunkPhase

ChunkPhase Cutelyst::ProtoRequestHttp::chunkPhase

Definition at line 120 of file protocolhttp.h.

◆ last

int Cutelyst::ProtoRequestHttp::last

Definition at line 116 of file protocolhttp.h.

◆ websocket_continue_opcode

quint8 Cutelyst::ProtoRequestHttp::websocket_continue_opcode

Definition at line 122 of file protocolhttp.h.

◆ websocket_finn_opcode

quint8 Cutelyst::ProtoRequestHttp::websocket_finn_opcode

Definition at line 123 of file protocolhttp.h.

◆ websocket_mask

quint32 Cutelyst::ProtoRequestHttp::websocket_mask

Definition at line 115 of file protocolhttp.h.

◆ websocket_message

QByteArray Cutelyst::ProtoRequestHttp::websocket_message

Definition at line 111 of file protocolhttp.h.

◆ websocket_need

quint32 Cutelyst::ProtoRequestHttp::websocket_need

Definition at line 114 of file protocolhttp.h.

◆ websocket_payload

QByteArray Cutelyst::ProtoRequestHttp::websocket_payload

Definition at line 112 of file protocolhttp.h.

◆ websocket_payload_size

quint64 Cutelyst::ProtoRequestHttp::websocket_payload_size

Definition at line 113 of file protocolhttp.h.

◆ websocket_phase

WebSocketPhase Cutelyst::ProtoRequestHttp::websocket_phase

Definition at line 119 of file protocolhttp.h.

◆ websocket_start_of_frame

int Cutelyst::ProtoRequestHttp::websocket_start_of_frame

Definition at line 118 of file protocolhttp.h.

◆ websocketUpgraded

bool Cutelyst::ProtoRequestHttp::websocketUpgraded

Definition at line 124 of file protocolhttp.h.