annotate include/core/http.h @ 278:c41c14ff8c67

dep/animone: x11: remove debugging comment oops
author Paper <paper@paper.us.eu.org>
date Mon, 22 Apr 2024 19:11:31 -0400
parents 3ec7804abf17
children 9a88e1725fd2
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
261
3ec7804abf17 include: make header guards more sane
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
1 #ifndef MINORI_CORE_HTTP_H_
3ec7804abf17 include: make header guards more sane
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
2 #define MINORI_CORE_HTTP_H_
75
d3e9310598b1 *: refactor some stuff
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
3
77
6f7385bd334c *: update
Paper <mrpapersonic@gmail.com>
parents: 76
diff changeset
4 #include <QByteArray>
230
2f5a9247e501 torrents: implement download button
Paper <paper@paper.us.eu.org>
parents: 100
diff changeset
5 #include <QThread>
75
d3e9310598b1 *: refactor some stuff
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
6 #include <string>
d3e9310598b1 *: refactor some stuff
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
7 #include <vector>
d3e9310598b1 *: refactor some stuff
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
8
d3e9310598b1 *: refactor some stuff
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
9 namespace HTTP {
d3e9310598b1 *: refactor some stuff
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
10
100
f5940a575d83 track/constants: add many more video formats
Paper <mrpapersonic@gmail.com>
parents: 77
diff changeset
11 QByteArray Get(const std::string& url, const std::vector<std::string>& headers = {});
f5940a575d83 track/constants: add many more video formats
Paper <mrpapersonic@gmail.com>
parents: 77
diff changeset
12 QByteArray Post(const std::string& url, const std::string& data, const std::vector<std::string>& headers = {});
75
d3e9310598b1 *: refactor some stuff
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
13
230
2f5a9247e501 torrents: implement download button
Paper <paper@paper.us.eu.org>
parents: 100
diff changeset
14 class GetThread : public QThread {
2f5a9247e501 torrents: implement download button
Paper <paper@paper.us.eu.org>
parents: 100
diff changeset
15 Q_OBJECT
2f5a9247e501 torrents: implement download button
Paper <paper@paper.us.eu.org>
parents: 100
diff changeset
16
2f5a9247e501 torrents: implement download button
Paper <paper@paper.us.eu.org>
parents: 100
diff changeset
17 public:
258
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
18 GetThread(const std::string& u, const std::vector<std::string>& h = {}, QObject* parent = nullptr)
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
19 : QThread(parent) {
230
2f5a9247e501 torrents: implement download button
Paper <paper@paper.us.eu.org>
parents: 100
diff changeset
20 url = u;
2f5a9247e501 torrents: implement download button
Paper <paper@paper.us.eu.org>
parents: 100
diff changeset
21 headers = h;
2f5a9247e501 torrents: implement download button
Paper <paper@paper.us.eu.org>
parents: 100
diff changeset
22 }
2f5a9247e501 torrents: implement download button
Paper <paper@paper.us.eu.org>
parents: 100
diff changeset
23
2f5a9247e501 torrents: implement download button
Paper <paper@paper.us.eu.org>
parents: 100
diff changeset
24 signals:
2f5a9247e501 torrents: implement download button
Paper <paper@paper.us.eu.org>
parents: 100
diff changeset
25 void ReceivedData(const QByteArray& ba);
2f5a9247e501 torrents: implement download button
Paper <paper@paper.us.eu.org>
parents: 100
diff changeset
26
2f5a9247e501 torrents: implement download button
Paper <paper@paper.us.eu.org>
parents: 100
diff changeset
27 protected:
258
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
28 void run() override { emit ReceivedData(Get(url, headers)); }
230
2f5a9247e501 torrents: implement download button
Paper <paper@paper.us.eu.org>
parents: 100
diff changeset
29
2f5a9247e501 torrents: implement download button
Paper <paper@paper.us.eu.org>
parents: 100
diff changeset
30 std::string url;
2f5a9247e501 torrents: implement download button
Paper <paper@paper.us.eu.org>
parents: 100
diff changeset
31 std::vector<std::string> headers;
2f5a9247e501 torrents: implement download button
Paper <paper@paper.us.eu.org>
parents: 100
diff changeset
32 };
2f5a9247e501 torrents: implement download button
Paper <paper@paper.us.eu.org>
parents: 100
diff changeset
33
2f5a9247e501 torrents: implement download button
Paper <paper@paper.us.eu.org>
parents: 100
diff changeset
34 class PostThread : public QThread {
2f5a9247e501 torrents: implement download button
Paper <paper@paper.us.eu.org>
parents: 100
diff changeset
35 Q_OBJECT
2f5a9247e501 torrents: implement download button
Paper <paper@paper.us.eu.org>
parents: 100
diff changeset
36
2f5a9247e501 torrents: implement download button
Paper <paper@paper.us.eu.org>
parents: 100
diff changeset
37 public:
258
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
38 PostThread(const std::string& u, const std::string& d, const std::vector<std::string>& h = {},
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
39 QObject* parent = nullptr)
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
40 : QThread(parent) {
230
2f5a9247e501 torrents: implement download button
Paper <paper@paper.us.eu.org>
parents: 100
diff changeset
41 url = u;
2f5a9247e501 torrents: implement download button
Paper <paper@paper.us.eu.org>
parents: 100
diff changeset
42 data = d;
2f5a9247e501 torrents: implement download button
Paper <paper@paper.us.eu.org>
parents: 100
diff changeset
43 headers = h;
2f5a9247e501 torrents: implement download button
Paper <paper@paper.us.eu.org>
parents: 100
diff changeset
44 }
2f5a9247e501 torrents: implement download button
Paper <paper@paper.us.eu.org>
parents: 100
diff changeset
45
2f5a9247e501 torrents: implement download button
Paper <paper@paper.us.eu.org>
parents: 100
diff changeset
46 signals:
2f5a9247e501 torrents: implement download button
Paper <paper@paper.us.eu.org>
parents: 100
diff changeset
47 void ReceivedData(const QByteArray& ba);
2f5a9247e501 torrents: implement download button
Paper <paper@paper.us.eu.org>
parents: 100
diff changeset
48
2f5a9247e501 torrents: implement download button
Paper <paper@paper.us.eu.org>
parents: 100
diff changeset
49 protected:
258
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 236
diff changeset
50 void run() override { emit ReceivedData(Post(url, data, headers)); }
230
2f5a9247e501 torrents: implement download button
Paper <paper@paper.us.eu.org>
parents: 100
diff changeset
51
2f5a9247e501 torrents: implement download button
Paper <paper@paper.us.eu.org>
parents: 100
diff changeset
52 std::string url;
2f5a9247e501 torrents: implement download button
Paper <paper@paper.us.eu.org>
parents: 100
diff changeset
53 std::string data;
2f5a9247e501 torrents: implement download button
Paper <paper@paper.us.eu.org>
parents: 100
diff changeset
54 std::vector<std::string> headers;
2f5a9247e501 torrents: implement download button
Paper <paper@paper.us.eu.org>
parents: 100
diff changeset
55 };
2f5a9247e501 torrents: implement download button
Paper <paper@paper.us.eu.org>
parents: 100
diff changeset
56
76
3364fadc8a36 *: format source code
Paper <mrpapersonic@gmail.com>
parents: 75
diff changeset
57 } // namespace HTTP
75
d3e9310598b1 *: refactor some stuff
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
58
261
3ec7804abf17 include: make header guards more sane
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
59 #endif // MINORI_CORE_HTTP_H_