Debian Codegraph @

src/librssguard/network-web/httpserver.cpp

raw symbols SCIP
1 // For license of this file, see <project-root-folder>/LICENSE.md.cxx . . $ `<file>/src/librssguard/network-web/httpserver.cpp`/
2
3 #include "network-web/httpserver.h"cxx . . $ `<file>/src/librssguard/network-web/httpserver.h`/
4
5 #include "definitions/definitions.h"cxx . . $ `<file>/src/librssguard/definitions/definitions.h`/
6
7 #include <QDateTime>
8
9 HttpServercxx . . $ HttpServer#::HttpServercxx . . $ HttpServer#HttpServer(749de1b6ae65bddd).(QObjectcxx . . $ QObject#* parent) : QObjectcxx . . $ QObject#QObject(749de1b6ae65bddd).(parent), m_listenAddresscxx . . $ HttpServer#m_listenAddress.(QHostAddresscxx . . $ QHostAddress#QHostAddress(49f6e7a06ebc5aa8).()), m_listenPortcxx . . $ HttpServer#m_listenPort.(0) {
10 connectcxx . . $ QObject#connect(dad3a9587f3dce3c).(&m_httpServercxx . . $ HttpServer#m_httpServer., &QTcpServercxx . . $ QTcpServer#::newConnectioncxx . . $ QTcpServer#newConnection(49f6e7a06ebc5aa8)., this, &HttpServercxx . . $ HttpServer#::clientConnectedcxx . . $ HttpServer#clientConnected(49f6e7a06ebc5aa8).);
11
12 // NOTE: We do not want to start handler immediately, sometimes
13 // we want to start it later, perhaps when correct redirect URL/port comes in.
14 }
15
16 HttpServercxx . . $ HttpServer#::~cxx . . $ HttpServer#`~HttpServer`(ced63f7c635d850d).HttpServercxx . . $ HttpServer#() {
17 if (m_httpServercxx . . $ HttpServer#m_httpServer..isListeningcxx . . $ QTcpServer#isListening(50ce9a9e25b4a850).()) {
18 qWarningNNcxx . . $ `src/librssguard/definitions/definitions.h:417:9`! <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). LOGSEC_NETWORKcxx . . $ `src/librssguard/definitions/definitions.h:168:9`! <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). "Redirection OAuth handler is listening. Stopping it now.";
19 stopcxx . . $ HttpServer#stop(49f6e7a06ebc5aa8).();
20 }
21 }
22
23 bool HttpServercxx . . $ HttpServer#::isListeningcxx . . $ HttpServer#isListening(50ce9a9e25b4a850).() const {
24 return m_httpServercxx . . $ HttpServer#m_httpServer..isListeningcxx . . $ QTcpServer#isListening(50ce9a9e25b4a850).();
25 }
26
27 void HttpServercxx . . $ HttpServer#::setListenAddressPortcxx . . $ HttpServer#setListenAddressPort(37c160c81b6367f7).(const QStringcxx . . $ QString#& full_uri, bool start_handler) {
28 QUrlcxx . . $ QUrl# url = QUrlcxx . . $ QUrl#::fromUserInputcxx . . $ QUrl#fromUserInput(6a862b781f6237c0).(full_uri);
29 QHostAddresscxx . . $ QHostAddress# listen_addresscxx . . $ QHostAddress#QHostAddress(49f6e7a06ebc5aa8).;
30 quint16cxx . . $ quint16# listen_port = quint16cxx . . $ quint16#(url.portcxx . . $ QUrl#port(7ccb52b1bfe01045).(80));
31
32 if (url.hostcxx . . $ QUrl#host(9d7420bec8bfe6c9).() ==cxx . . $ `operator==`(361382e1f96e31f0). QL1Scxx . . $ `src/librssguard/definitions/definitions.h:449:9`!("localhost")) {
33 listen_address =cxx . . $ QHostAddress#`operator=`(73b0b25f699f75b1). QHostAddresscxx . . $ QHostAddress#QHostAddress(87181e547927ba53).(QHostAddresscxx . . $ QHostAddress#::SpecialAddresscxx . . $ QHostAddress#SpecialAddress#::LocalHostcxx . . $ QHostAddress#LocalHost.);
34 }
35 else {
36 listen_address =cxx . . $ QHostAddress#`operator=`(73b0b25f699f75b1). QHostAddresscxx . . $ QHostAddress#QHostAddress(3520e46b33348bf6).(url.hostcxx . . $ QUrl#host(9d7420bec8bfe6c9).());
37 }
38
39 if (listen_address ==cxx . . $ QHostAddress#`operator==`(36ca15464ce2ec3c). m_listenAddresscxx . . $ HttpServer#m_listenAddress. && listen_port == m_listenPortcxx . . $ HttpServer#m_listenPort. && start_handler == m_httpServercxx . . $ HttpServer#m_httpServer..isListeningcxx . . $ QTcpServer#isListening(50ce9a9e25b4a850).()) {
40 // NOTE: We do not need to change listener's settings or re-start it.
41 return;
42 }
43
44 if (m_httpServercxx . . $ HttpServer#m_httpServer..isListeningcxx . . $ QTcpServer#isListening(50ce9a9e25b4a850).()) {
45 qWarningNNcxx . . $ `src/librssguard/definitions/definitions.h:417:9`! <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). LOGSEC_NETWORKcxx . . $ `src/librssguard/definitions/definitions.h:168:9`! <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). "Redirection OAuth handler is listening. Stopping it now.";
46 stopcxx . . $ HttpServer#stop(49f6e7a06ebc5aa8).();
47 }
48
49 m_listenAddresscxx . . $ HttpServer#m_listenAddress. =cxx . . $ QHostAddress#`operator=`(43b6ece1101b6659). listen_address;
50 m_listenPortcxx . . $ HttpServer#m_listenPort. = listen_port;
51 m_listenAddressPortcxx . . $ HttpServer#m_listenAddressPort. =cxx . . $ QString#`operator=`(b79fde0b0ce9b948). full_uri;
52
53 if (!start_handler) {
54 qDebugNNcxx . . $ `src/librssguard/definitions/definitions.h:413:9`! <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). LOGSEC_NETWORKcxx . . $ `src/librssguard/definitions/definitions.h:168:9`! <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). "User does not want handler to be running.";
55 return;
56 }
57
58 if (!m_httpServercxx . . $ HttpServer#m_httpServer..listencxx . . $ QTcpServer#listen(6fdb1d868b5163ab).(listen_address, listen_port)) {
59 qCriticalNNcxx . . $ `src/librssguard/definitions/definitions.h:421:9`! <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). LOGSEC_NETWORKcxx . . $ `src/librssguard/definitions/definitions.h:168:9`! <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). "OAuth redirect handler FAILED TO START TO LISTEN on address"
60 <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). QUOTE_W_SPACEcxx . . $ `src/librssguard/definitions/definitions.h:432:9`!(listen_address.toString()) <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). "and port" <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). QUOTE_W_SPACEcxx . . $ `src/librssguard/definitions/definitions.h:432:9`!(listen_port) <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). "with error"
61 <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). QUOTE_W_SPACE_DOTcxx . . $ `src/librssguard/definitions/definitions.h:430:9`!(m_httpServer.errorString());
62 }
63 else {
64 qDebugNNcxx . . $ `src/librssguard/definitions/definitions.h:413:9`! <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). LOGSEC_NETWORKcxx . . $ `src/librssguard/definitions/definitions.h:168:9`! <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). "OAuth redirect handler IS LISTENING on address"
65 <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). QUOTE_W_SPACEcxx . . $ `src/librssguard/definitions/definitions.h:432:9`!(m_listenAddress.toString()) <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). "and port" <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). QUOTE_W_SPACE_DOTcxx . . $ `src/librssguard/definitions/definitions.h:430:9`!(m_listenPort);
66 }
67 }
68
69 QByteArraycxx . . $ QByteArray# HttpServercxx . . $ HttpServer#::generateHttpAnswercxx . . $ HttpServer#generateHttpAnswer(bd41d2748839d377).(int http_code,
70 const QListcxx . . $ QList#<HttpHeadercxx . . $ HttpServer#HttpHeader#>& headers,
71 const QByteArraycxx . . $ QByteArray#& body) const {
72 QListcxx . . $ QList#<HttpHeadercxx . . $ HttpServer#HttpHeader#> my_headers = headers;
73 QByteArraycxx . . $ QByteArray# answer = QSLcxx . . $ `src/librssguard/definitions/definitions.h:442:9`!("HTTP/1.0 %1 \r\n").argcxx . . $ QString#arg(ed67e9a87de2cd4e).(http_code).toLocal8Bitcxx . . $ QString#toLocal8Bit(7c2073558a834e49).();
74 int body_length = body.sizecxx . . $ QByteArray#size(6b0412d51016192f).();
75
76 // Append body length.
77 if (body_length > 0) {
78 my_headers.appendcxx . . $ QList#append(1262c8661f7a27a7).({QSLcxx . . $ `src/librssguard/definitions/definitions.h:442:9`!("Content-Length"), QStringcxx . . $ QString#::numbercxx . . $ QString#number(f4fd9db251ca774b).(body_length)});
79 }
80
81 // Append server ID and other common headers.
82 my_headers.appendcxx . . $ QList#append(1262c8661f7a27a7).({QSLcxx . . $ `src/librssguard/definitions/definitions.h:442:9`!("Date"), QDateTimecxx . . $ QDateTime#::currentDateTimeUtccxx . . $ QDateTime#currentDateTimeUtc(bf5129c8228c71c0).().toStringcxx . . $ QDateTime#toString(7b7e68bded046f2f).(Qtcxx . . $ Qt/::DateFormatcxx . . $ Qt/DateFormat#::RFC2822Datecxx . . $ Qt/RFC2822Date.)});
83 my_headers.appendcxx . . $ QList#append(1262c8661f7a27a7).({QSLcxx . . $ `src/librssguard/definitions/definitions.h:442:9`!("Server"), QSLcxx . . $ `src/librssguard/definitions/definitions.h:442:9`!(APP_LONG_NAMEcxx . . $ `<built-in>:484:9`!)});
84
85 for (const HttpHeadercxx . . $ HttpServer#HttpHeader#& header : my_headers) {
86 answer.appendcxx . . $ QByteArray#append(85c7caed82076bbb).(QSLcxx . . $ `src/librssguard/definitions/definitions.h:442:9`!("%1: %2\r\n").argcxx . . $ QString#arg(89b093bd48b6d6c0).(header.m_namecxx . . $ HttpServer#HttpHeader#m_name., header.m_valuecxx . . $ HttpServer#HttpHeader#m_value.).toLocal8Bitcxx . . $ QString#toLocal8Bit(7c2073558a834e49).());
87 }
88
89 answer.appendcxx . . $ QByteArray#append(85c7caed82076bbb).(QSLcxx . . $ `src/librssguard/definitions/definitions.h:442:9`!("\r\n").toLocal8Bitcxx . . $ QString#toLocal8Bit(7c2073558a834e49).());
90
91 if (body_length > 0) {
92 answer.appendcxx . . $ QByteArray#append(85c7caed82076bbb).(body);
93 }
94
95 return answercxx . . $ QByteArray#QByteArray(9f1b912973d89fea).;
96 }
97
98 void HttpServercxx . . $ HttpServer#::clientConnectedcxx . . $ HttpServer#clientConnected(49f6e7a06ebc5aa8).() {
99 QTcpSocketcxx . . $ QTcpSocket#* socket = m_httpServercxx . . $ HttpServer#m_httpServer..nextPendingConnectioncxx . . $ QTcpServer#nextPendingConnection(3b0f0a12ef6ae0dd).();
100
101 QObjectcxx . . $ QObject#::connectcxx . . $ QObject#connect(dad3a9587f3dce3c).(socket, &QTcpSocketcxx . . $ QTcpSocket#::disconnectedcxx . . $ QAbstractSocket#disconnected(49f6e7a06ebc5aa8)., socket, &QTcpSocketcxx . . $ QTcpSocket#::deleteLatercxx . . $ QObject#deleteLater(49f6e7a06ebc5aa8).);
102 QObjectcxx . . $ QObject#::connectcxx . . $ QObject#connect(93770ac28d6bf547).(socket, &QTcpSocketcxx . . $ QTcpSocket#::readyReadcxx . . $ QIODevice#readyRead(49f6e7a06ebc5aa8)., [this, socket]() {
103 readReceivedDatacxx . . $ HttpServer#readReceivedData(214e24de1d575aa3).(socket);
104 });
105 }
106
107 void HttpServercxx . . $ HttpServer#::readReceivedDatacxx . . $ HttpServer#readReceivedData(214e24de1d575aa3).(QTcpSocketcxx . . $ QTcpSocket#* socket) {
108 if (!m_connectedClientscxx . . $ HttpServer#m_connectedClients..containscxx . . $ QMap#contains(8877ebe272b9620d).(socket)) {
109 m_connectedClientscxx . . $ HttpServer#m_connectedClients.[cxx . . $ QMap#`operator[]`(bbd415b616967878).socket].m_addresscxx . . $ HttpServer#HttpRequest#m_address. =cxx . . $ QString#`operator=`(4f35bf974e7f8568). QSLcxx . . $ `src/librssguard/definitions/definitions.h:442:9`!(URI_SCHEME_HTTPcxx . . $ `src/librssguard/definitions/definitions.h:35:9`!) + m_httpServercxx . . $ HttpServer#m_httpServer..serverAddresscxx . . $ QTcpServer#serverAddress(324da51e91434ec8).().toStringcxx . . $ QHostAddress#toString(6ef7b6c27b00b43d).();
110 m_connectedClientscxx . . $ HttpServer#m_connectedClients.[cxx . . $ QMap#`operator[]`(bbd415b616967878).socket].m_portcxx . . $ HttpServer#HttpRequest#m_port. = m_httpServercxx . . $ HttpServer#m_httpServer..serverPortcxx . . $ QTcpServer#serverPort(72085aa11f4b6e09).();
111 }
112
113 HttpRequestcxx . . $ HttpServer#HttpRequest#* request = &m_connectedClientscxx . . $ HttpServer#m_connectedClients.[cxx . . $ QMap#`operator[]`(bbd415b616967878).socket];
114 bool error = false;
115
116 if (Q_LIKELYcxx . . $ `<external>/13147557517174114922/qcompilerdetection.h:207:11`!(request->m_state == HttpRequest::State::ReadingMethod)) {
117 if (Q_UNLIKELYcxx . . $ `<external>/13147557517174114922/qcompilerdetection.h:208:11`!(error = !request->readMethod(socket))) {
118 qWarningNNcxx . . $ `src/librssguard/definitions/definitions.h:417:9`! <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). LOGSEC_NETWORKcxx . . $ `src/librssguard/definitions/definitions.h:168:9`! <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). "Invalid method.";
119 }
120 }
121
122 if (Q_LIKELYcxx . . $ `<external>/13147557517174114922/qcompilerdetection.h:207:11`!(!error && request->m_state == HttpRequest::State::ReadingUrl)) {
123 if (Q_UNLIKELYcxx . . $ `<external>/13147557517174114922/qcompilerdetection.h:208:11`!(error = !request->readUrl(socket))) {
124 qWarningNNcxx . . $ `src/librssguard/definitions/definitions.h:417:9`! <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). LOGSEC_NETWORKcxx . . $ `src/librssguard/definitions/definitions.h:168:9`! <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). "Invalid URL.";
125 }
126 }
127
128 if (Q_LIKELYcxx . . $ `<external>/13147557517174114922/qcompilerdetection.h:207:11`!(!error && request->m_state == HttpRequest::State::ReadingStatus)) {
129 if (Q_UNLIKELYcxx . . $ `<external>/13147557517174114922/qcompilerdetection.h:208:11`!(error = !request->readStatus(socket))) {
130 qWarningNNcxx . . $ `src/librssguard/definitions/definitions.h:417:9`! <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). LOGSEC_NETWORKcxx . . $ `src/librssguard/definitions/definitions.h:168:9`! <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). "Invalid status.";
131 }
132 }
133
134 if (Q_LIKELYcxx . . $ `<external>/13147557517174114922/qcompilerdetection.h:207:11`!(!error && request->m_state == HttpRequest::State::ReadingHeader)) {
135 if (Q_UNLIKELYcxx . . $ `<external>/13147557517174114922/qcompilerdetection.h:208:11`!(error = !request->readHeader(socket))) {
136 qWarningNNcxx . . $ `src/librssguard/definitions/definitions.h:417:9`! <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). LOGSEC_NETWORKcxx . . $ `src/librssguard/definitions/definitions.h:168:9`! <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). "Invalid header.";
137 }
138 }
139
140 if (error) {
141 socket->disconnectFromHostcxx . . $ QAbstractSocket#disconnectFromHost(49f6e7a06ebc5aa8).();
142 m_connectedClientscxx . . $ HttpServer#m_connectedClients..removecxx . . $ QMap#remove(ab653331f366a553).(socket);
143 }
144 else if (!request->m_urlcxx . . $ HttpServer#HttpRequest#m_url..isEmptycxx . . $ QUrl#isEmpty(50ce9a9e25b4a850).()) {
145 Q_ASSERTcxx . . $ `<external>/4968608585795071363/qassert.h:29:13`!(request->m_state != HttpRequest::State::ReadingUrl);
146
147 answerClientcxx . . $ HttpServer#answerClient(3437f9300e7c8f28).(socket, *request);
148 m_connectedClientscxx . . $ HttpServer#m_connectedClients..removecxx . . $ QMap#remove(ab653331f366a553).(socket);
149 }
150 }
151
152 QHostAddresscxx . . $ QHostAddress# HttpServercxx . . $ HttpServer#::listenAddresscxx . . $ HttpServer#listenAddress(324da51e91434ec8).() const {
153 return m_listenAddresscxx . . $ QHostAddress#QHostAddress(b05438ebbfcf3274).;
154 }
155
156 QStringcxx . . $ QString# HttpServercxx . . $ HttpServer#::listenAddressPortcxx . . $ HttpServer#listenAddressPort(6ef7b6c27b00b43d).() const {
157 return m_listenAddressPortcxx . . $ QString#QString(132dd6869045752b).;
158 }
159
160 quint16cxx . . $ quint16# HttpServercxx . . $ HttpServer#::listenPortcxx . . $ HttpServer#listenPort(72085aa11f4b6e09).() const {
161 return m_listenPortcxx . . $ HttpServer#m_listenPort.;
162 }
163
164 bool HttpServercxx . . $ HttpServer#::HttpRequestcxx . . $ HttpServer#HttpRequest#::readMethodcxx . . $ HttpServer#HttpRequest#readMethod(25ee3d08cd9f19c0).(QTcpSocketcxx . . $ QTcpSocket#* socket) {
165 bool finished = false;
166
167 while ((socket->bytesAvailablecxx . . $ QAbstractSocket#bytesAvailable(98833e9ab7de59a4).() != 0) && !finished) {
168 const auto c = socket->readcxx . . $ QIODevice#read(1117a85f2fd4e5c8).(1).atcxx . . $ QByteArray#at(ac5a1ee720dcf605).(0);
169
170 if ((stdcxx . . $ std/::isuppercxx . . $ std/isupper(a1851578aea3f541).(c) != 0) && m_fragmentcxx . . $ HttpServer#HttpRequest#m_fragment..sizecxx . . $ QByteArray#size(6b0412d51016192f).() < 7) {
171 m_fragmentcxx . . $ HttpServer#HttpRequest#m_fragment. +=cxx . . $ QByteArray#`operator+=`(1815c0e4073627df). c;
172 }
173 else {
174 finished = true;
175 }
176 }
177
178 if (finished) {
179 if (m_fragmentcxx . . $ HttpServer#HttpRequest#m_fragment. ==cxx . . $ `operator==`(bb32baa670f2732c). "HEAD") {
180 m_methodcxx . . $ HttpServer#HttpRequest#m_method. = Methodcxx . . $ HttpServer#HttpRequest#Method#::Headcxx . . $ HttpServer#HttpRequest#Method#Head.;
181 }
182 else if (m_fragmentcxx . . $ HttpServer#HttpRequest#m_fragment. ==cxx . . $ `operator==`(bb32baa670f2732c). "GET") {
183 m_methodcxx . . $ HttpServer#HttpRequest#m_method. = Methodcxx . . $ HttpServer#HttpRequest#Method#::Getcxx . . $ HttpServer#HttpRequest#Method#Get.;
184 }
185 else if (m_fragmentcxx . . $ HttpServer#HttpRequest#m_fragment. ==cxx . . $ `operator==`(bb32baa670f2732c). "PUT") {
186 m_methodcxx . . $ HttpServer#HttpRequest#m_method. = Methodcxx . . $ HttpServer#HttpRequest#Method#::Putcxx . . $ HttpServer#HttpRequest#Method#Put.;
187 }
188 else if (m_fragmentcxx . . $ HttpServer#HttpRequest#m_fragment. ==cxx . . $ `operator==`(bb32baa670f2732c). "POST") {
189 m_methodcxx . . $ HttpServer#HttpRequest#m_method. = Methodcxx . . $ HttpServer#HttpRequest#Method#::Postcxx . . $ HttpServer#HttpRequest#Method#Post.;
190 }
191 else if (m_fragmentcxx . . $ HttpServer#HttpRequest#m_fragment. ==cxx . . $ `operator==`(bb32baa670f2732c). "DELETE") {
192 m_methodcxx . . $ HttpServer#HttpRequest#m_method. = Methodcxx . . $ HttpServer#HttpRequest#Method#::Deletecxx . . $ HttpServer#HttpRequest#Method#Delete.;
193 }
194 else if (m_fragmentcxx . . $ HttpServer#HttpRequest#m_fragment. ==cxx . . $ `operator==`(bb32baa670f2732c). "OPTIONS") {
195 m_methodcxx . . $ HttpServer#HttpRequest#m_method. = Methodcxx . . $ HttpServer#HttpRequest#Method#::Optionscxx . . $ HttpServer#HttpRequest#Method#Options.;
196 }
197 else {
198 qWarningNNcxx . . $ `src/librssguard/definitions/definitions.h:417:9`! <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). LOGSEC_NETWORKcxx . . $ `src/librssguard/definitions/definitions.h:168:9`! <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). "Invalid operation:" <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). QUOTE_W_SPACE_DOTcxx . . $ `src/librssguard/definitions/definitions.h:430:9`!(m_fragment.data());
199 }
200
201 m_statecxx . . $ HttpServer#HttpRequest#m_state. = Statecxx . . $ HttpServer#HttpRequest#State#::ReadingUrlcxx . . $ HttpServer#HttpRequest#State#ReadingUrl.;
202 m_fragmentcxx . . $ HttpServer#HttpRequest#m_fragment..clearcxx . . $ QByteArray#clear(49f6e7a06ebc5aa8).();
203
204 return m_methodcxx . . $ HttpServer#HttpRequest#m_method. != Methodcxx . . $ HttpServer#HttpRequest#Method#::Unknowncxx . . $ HttpServer#HttpRequest#Method#Unknown.;
205 }
206
207 return true;
208 }
209
210 bool HttpServercxx . . $ HttpServer#::HttpRequestcxx . . $ HttpServer#HttpRequest#::readUrlcxx . . $ HttpServer#HttpRequest#readUrl(25ee3d08cd9f19c0).(QTcpSocketcxx . . $ QTcpSocket#* socket) {
211 bool finished = false;
212
213 while ((socket->bytesAvailablecxx . . $ QAbstractSocket#bytesAvailable(98833e9ab7de59a4).() != 0) && !finished) {
214 const auto c = socket->readcxx . . $ QIODevice#read(1117a85f2fd4e5c8).(1).atcxx . . $ QByteArray#at(ac5a1ee720dcf605).(0);
215
216 if (stdcxx . . $ std/::isspacecxx . . $ std/isspace(a1851578aea3f541).(c) != 0) {
217 finished = true;
218 }
219 else {
220 m_fragmentcxx . . $ HttpServer#HttpRequest#m_fragment. +=cxx . . $ QByteArray#`operator+=`(1815c0e4073627df). c;
221 }
222 }
223
224 if (finished) {
225 if (!m_fragmentcxx . . $ HttpServer#HttpRequest#m_fragment..startsWithcxx . . $ QByteArray#startsWith(e458f63ed7c3a81a).("/"cxx . . $ QByteArrayView#QByteArrayView(f681811f58ba18b0).)) {
226 qWarningNNcxx . . $ `src/librssguard/definitions/definitions.h:417:9`! <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). LOGSEC_NETWORKcxx . . $ `src/librssguard/definitions/definitions.h:168:9`! <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). "Invalid URL path" <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). QUOTE_W_SPACE_DOTcxx . . $ `src/librssguard/definitions/definitions.h:430:9`!(m_fragment);
227 return false;
228 }
229
230 m_urlcxx . . $ HttpServer#HttpRequest#m_url..setUrlcxx . . $ QUrl#setUrl(ea1f3831e370f1cb).(m_addresscxx . . $ HttpServer#HttpRequest#m_address. + QStringcxx . . $ QString#::numbercxx . . $ QString#number(f4fd9db251ca774b).(m_portcxx . . $ HttpServer#HttpRequest#m_port.) + QStringcxx . . $ QString#::fromUtf8cxx . . $ QString#fromUtf8(4e15edac36d215be).(m_fragmentcxx . . $ HttpServer#HttpRequest#m_fragment.));
231 m_statecxx . . $ HttpServer#HttpRequest#m_state. = Statecxx . . $ HttpServer#HttpRequest#State#::ReadingStatuscxx . . $ HttpServer#HttpRequest#State#ReadingStatus.;
232
233 if (!m_urlcxx . . $ HttpServer#HttpRequest#m_url..isValidcxx . . $ QUrl#isValid(50ce9a9e25b4a850).()) {
234 qWarningNNcxx . . $ `src/librssguard/definitions/definitions.h:417:9`! <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). LOGSEC_NETWORKcxx . . $ `src/librssguard/definitions/definitions.h:168:9`! <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). "Invalid URL" <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). QUOTE_W_SPACE_DOTcxx . . $ `src/librssguard/definitions/definitions.h:430:9`!(m_fragment);
235 return false;
236 }
237
238 m_fragmentcxx . . $ HttpServer#HttpRequest#m_fragment..clearcxx . . $ QByteArray#clear(49f6e7a06ebc5aa8).();
239 return true;
240 }
241
242 return true;
243 }
244
245 bool HttpServercxx . . $ HttpServer#::HttpRequestcxx . . $ HttpServer#HttpRequest#::readStatuscxx . . $ HttpServer#HttpRequest#readStatus(25ee3d08cd9f19c0).(QTcpSocketcxx . . $ QTcpSocket#* socket) {
246 bool finished = false;
247
248 while ((socket->bytesAvailablecxx . . $ QAbstractSocket#bytesAvailable(98833e9ab7de59a4).() != 0) && !finished) {
249 m_fragmentcxx . . $ HttpServer#HttpRequest#m_fragment. +=cxx . . $ QByteArray#`operator+=`(85c7caed82076bbb). socket->readcxx . . $ QIODevice#read(1117a85f2fd4e5c8).(1);
250
251 if (m_fragmentcxx . . $ HttpServer#HttpRequest#m_fragment..endsWithcxx . . $ QByteArray#endsWith(e458f63ed7c3a81a).("\r\n"cxx . . $ QByteArrayView#QByteArrayView(f681811f58ba18b0).)) {
252 finished = true;
253 m_fragmentcxx . . $ HttpServer#HttpRequest#m_fragment..resizecxx . . $ QByteArray#resize(35cb52607f6af42f).(m_fragmentcxx . . $ HttpServer#HttpRequest#m_fragment..sizecxx . . $ QByteArray#size(6b0412d51016192f).() - 2);
254 }
255 }
256
257 if (finished) {
258 if ((stdcxx . . $ std/::isdigitcxx . . $ std/isdigit(a1851578aea3f541).(m_fragmentcxx . . $ HttpServer#HttpRequest#m_fragment..atcxx . . $ QByteArray#at(ac5a1ee720dcf605).(m_fragmentcxx . . $ HttpServer#HttpRequest#m_fragment..sizecxx . . $ QByteArray#size(6b0412d51016192f).() - 3)) == 0) ||
259 (stdcxx . . $ std/::isdigitcxx . . $ std/isdigit(a1851578aea3f541).(m_fragmentcxx . . $ HttpServer#HttpRequest#m_fragment..atcxx . . $ QByteArray#at(ac5a1ee720dcf605).(m_fragmentcxx . . $ HttpServer#HttpRequest#m_fragment..sizecxx . . $ QByteArray#size(6b0412d51016192f).() - 1)) == 0)) {
260 qWarningNNcxx . . $ `src/librssguard/definitions/definitions.h:417:9`! <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). LOGSEC_NETWORKcxx . . $ `src/librssguard/definitions/definitions.h:168:9`! <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). "Invalid version";
261 return false;
262 }
263
264 m_versioncxx . . $ HttpServer#HttpRequest#m_version. =cxx . . $ std/pair#`operator=`(3ac34a030569edbc). qMakePaircxx . . $ qMakePair(31357aa3a6f24cc0).(m_fragmentcxx . . $ HttpServer#HttpRequest#m_fragment..atcxx . . $ QByteArray#at(ac5a1ee720dcf605).(m_fragmentcxx . . $ HttpServer#HttpRequest#m_fragment..sizecxx . . $ QByteArray#size(6b0412d51016192f).() - 3) - '0', m_fragmentcxx . . $ HttpServer#HttpRequest#m_fragment..atcxx . . $ QByteArray#at(ac5a1ee720dcf605).(m_fragmentcxx . . $ HttpServer#HttpRequest#m_fragment..sizecxx . . $ QByteArray#size(6b0412d51016192f).() - 1) - '0');
265 m_statecxx . . $ HttpServer#HttpRequest#m_state. = Statecxx . . $ HttpServer#HttpRequest#State#::ReadingHeadercxx . . $ HttpServer#HttpRequest#State#ReadingHeader.;
266 m_fragmentcxx . . $ HttpServer#HttpRequest#m_fragment..clearcxx . . $ QByteArray#clear(49f6e7a06ebc5aa8).();
267 }
268
269 return true;
270 }
271
272 bool HttpServercxx . . $ HttpServer#::HttpRequestcxx . . $ HttpServer#HttpRequest#::readHeadercxx . . $ HttpServer#HttpRequest#readHeader(25ee3d08cd9f19c0).(QTcpSocketcxx . . $ QTcpSocket#* socket) {
273 while (socket->bytesAvailablecxx . . $ QAbstractSocket#bytesAvailable(98833e9ab7de59a4).() != 0) {
274 m_fragmentcxx . . $ HttpServer#HttpRequest#m_fragment. +=cxx . . $ QByteArray#`operator+=`(85c7caed82076bbb). socket->readcxx . . $ QIODevice#read(1117a85f2fd4e5c8).(1);
275
276 if (m_fragmentcxx . . $ HttpServer#HttpRequest#m_fragment..endsWithcxx . . $ QByteArray#endsWith(e458f63ed7c3a81a).("\r\n"cxx . . $ QByteArrayView#QByteArrayView(f681811f58ba18b0).)) {
277 if (m_fragmentcxx . . $ HttpServer#HttpRequest#m_fragment. ==cxx . . $ `operator==`(bb32baa670f2732c). "\r\n") {
278 m_statecxx . . $ HttpServer#HttpRequest#m_state. = Statecxx . . $ HttpServer#HttpRequest#State#::ReadingBodycxx . . $ HttpServer#HttpRequest#State#ReadingBody.;
279 m_fragmentcxx . . $ HttpServer#HttpRequest#m_fragment..clearcxx . . $ QByteArray#clear(49f6e7a06ebc5aa8).();
280 return true;
281 }
282 else {
283 m_fragmentcxx . . $ HttpServer#HttpRequest#m_fragment..chopcxx . . $ QByteArray#chop(35cb52607f6af42f).(2);
284 const int index = m_fragmentcxx . . $ HttpServer#HttpRequest#m_fragment..indexOfcxx . . $ QByteArray#indexOf(8862eafca515a5ad).(':');
285
286 if (index == -1) {
287 return false;
288 }
289
290 const QByteArraycxx . . $ QByteArray# key = m_fragmentcxx . . $ HttpServer#HttpRequest#m_fragment..midcxx . . $ QByteArray#mid(88d472d02baa9f48).(0, index).trimmedcxx . . $ QByteArray#trimmed(7c2073558a834e49).();
291 const QByteArraycxx . . $ QByteArray# value = m_fragmentcxx . . $ HttpServer#HttpRequest#m_fragment..midcxx . . $ QByteArray#mid(88d472d02baa9f48).(index + 1).trimmedcxx . . $ QByteArray#trimmed(7c2073558a834e49).();
292
293 m_headerscxx . . $ HttpServer#HttpRequest#m_headers..insertcxx . . $ QMap#insert(929a1ed410fe8423).(key, value);
294 m_fragmentcxx . . $ HttpServer#HttpRequest#m_fragment..clearcxx . . $ QByteArray#clear(49f6e7a06ebc5aa8).();
295 }
296 }
297 }
298
299 return false;
300 }
301
302 void HttpServercxx . . $ HttpServer#::stopcxx . . $ HttpServer#stop(49f6e7a06ebc5aa8).() {
303 m_httpServercxx . . $ HttpServer#m_httpServer..closecxx . . $ QTcpServer#close(49f6e7a06ebc5aa8).();
304 m_connectedClientscxx . . $ HttpServer#m_connectedClients..clearcxx . . $ QMap#clear(49f6e7a06ebc5aa8).();
305 m_listenAddresscxx . . $ HttpServer#m_listenAddress. =cxx . . $ QHostAddress#`operator=`(73b0b25f699f75b1). QHostAddresscxx . . $ QHostAddress#QHostAddress(49f6e7a06ebc5aa8).();
306 m_listenPortcxx . . $ HttpServer#m_listenPort. = 0;
307 m_listenAddressPortcxx . . $ HttpServer#m_listenAddressPort. =cxx . . $ QString#`operator=`(4f35bf974e7f8568). QStringcxx . . $ QString#QString(ced63f7c635d850d).();
308
309 qDebugNNcxx . . $ `src/librssguard/definitions/definitions.h:413:9`! <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). LOGSEC_NETWORKcxx . . $ `src/librssguard/definitions/definitions.h:168:9`! <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). "Stopped redirection handler.";
310 }