1// Copyright (C) 2022 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3
4#ifndef QHTTPSERVERSTREAM_P_H
5#define QHTTPSERVERSTREAM_P_H
6
7#include <QtCore/qobject.h>
8
9#include <QtHttpServer/qthttpserverglobal.h>
10#include <QtHttpServer/qhttpserverrequest.h>
11
12//
13// W A R N I N G
14// -------------
15//
16// This file is not part of the Qt API. It exists for the convenience
17// of QHttpServer. This header file may change from version to
18// version without notice, or even be removed.
19//
20// We mean it.
21
22QT_BEGIN_NAMESPACE
23
24class QTcpSocket;
25class QAbstractHttpServer;
26
27class QHttpServerStream : public QObject
28{
29 Q_OBJECT
30
31 friend class QAbstractHttpServerPrivate;
32 friend class QHttpServerResponder;
33
34private:
35 QHttpServerStream(QAbstractHttpServer *server, QTcpSocket *socket);
36
37 void write(const QByteArray &data);
38 void write(const char *body, qint64 size);
39
40 void responderDestroyed();
41
42 void handleReadyRead();
43 void socketDisconnected();
44
45 QAbstractHttpServer *server;
46 QTcpSocket *socket;
47
48 QHttpServerRequest request;
49
50 // To avoid destroying the object when socket object is destroyed while
51 // a request is still being handled.
52 bool handlingRequest = false;
53};
54
55QT_END_NAMESPACE
56
57#endif // QHTTPSERVERSTREAM_P_H
58

source code of qthttpserver/src/httpserver/qhttpserverstream_p.h