cutelyst 4.3.0
A C++ Web Framework built on top of Qt, using the simple approach of Catalyst (Perl) framework.
protocolfastcgi.h
1/*
2 * SPDX-FileCopyrightText: (C) 2017-2018 Daniel Nicoletti <dantti12@gmail.com>
3 * SPDX-License-Identifier: BSD-3-Clause
4 */
5#ifndef PROTOCOLFASTCGI_H
6#define PROTOCOLFASTCGI_H
7
8#include "protocol.h"
9#include "socket.h"
10
11#include <Cutelyst/Context>
12
13#include <QObject>
14
15namespace Cutelyst {
16
17class Server;
19 : public ProtocolData
21{
22 Q_GADGET
23public:
24 ProtoRequestFastCGI(Socket *sock, int bufferSize);
25 ~ProtoRequestFastCGI() override;
26
27 void setupNewConnection(Socket *sock) override;
28
29 bool writeHeaders(quint16 status, const Cutelyst::Headers &headers) override final;
30
31 qint64 doWrite(const char *data, qint64 len) override final;
32
33 inline qint64 doWrite(const QByteArray &data) { return doWrite(data.constData(), data.size()); }
34
35 void processingFinished() override final;
36
37 inline void resetData() override final
38 {
39 ProtocolData::resetData();
40
41 // EngineRequest
42 // If we deleteLater the context, there might
43 // be an event that tries to finalize the request
44 // and it will encounter a null context pointer
45 delete context;
46 context = nullptr;
47 body = nullptr;
48
49 startOfRequest = TimePointSteady{};
50 status = InitialState;
51
52 stream_id = 0;
53 pktsize = 0;
54 }
55
56public:
57 quint16 stream_id = 0;
58 quint16 pktsize = 0;
59};
60
61class ProtocolFastCGI final : public Protocol
62{
63public:
65 ~ProtocolFastCGI() override;
66
67 Type type() const override;
68
69 inline qint64 readBody(Socket *socket, QIODevice *io, qint64 bytesAvailable) const;
70 void parse(Socket *sock, QIODevice *io) const override final;
71
72 ProtocolData *createData(Socket *sock) const override final;
73
74private:
75 inline quint16 addHeader(ProtoRequestFastCGI *request,
76 const char *key,
77 quint16 keylen,
78 const char *val,
79 quint16 vallen) const;
80 inline int parseHeaders(ProtoRequestFastCGI *request, const char *buf, quint16 len) const;
81 inline int processPacket(ProtoRequestFastCGI *request) const;
82 inline bool writeBody(ProtoRequestFastCGI *request, char *buf, qint64 len) const;
83};
84
85} // namespace Cutelyst
86
87#endif // PROTOCOLFASTCGI_H
TimePointSteady startOfRequest
Container for HTTP headers.
Definition headers.h:24
bool writeHeaders(quint16 status, const Cutelyst::Headers &headers) override final
qint64 doWrite(const char *data, qint64 len) override final
void processingFinished() override final
Implements a web server.
Definition server.h:60
The Cutelyst namespace holds all public Cutelyst API.
const char * constData() const const
qsizetype size() const const