annotate include/core/http.h @ 252:a0eeb2cc7e6d

*: resolve make distcheck failures
author Paper <paper@paper.us.eu.org>
date Tue, 06 Feb 2024 02:24:49 -0500
parents 4d461ef7d424
children 862d0d8619f6
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
75
d3e9310598b1 *: refactor some stuff
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
1 #ifndef __core__http_h
d3e9310598b1 *: refactor some stuff
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
2 #define __core__http_h
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:
236
4d461ef7d424 HUGE UPDATE: convert build system to autotools
Paper <mrpapersonic@gmail.com>
parents: 230
diff changeset
18 GetThread(const std::string& u, const std::vector<std::string>& h = {}, QObject* parent = nullptr) : QThread(parent) {
230
2f5a9247e501 torrents: implement download button
Paper <paper@paper.us.eu.org>
parents: 100
diff changeset
19 url = u;
2f5a9247e501 torrents: implement download button
Paper <paper@paper.us.eu.org>
parents: 100
diff changeset
20 headers = h;
2f5a9247e501 torrents: implement download button
Paper <paper@paper.us.eu.org>
parents: 100
diff changeset
21 }
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 signals:
2f5a9247e501 torrents: implement download button
Paper <paper@paper.us.eu.org>
parents: 100
diff changeset
24 void ReceivedData(const QByteArray& ba);
2f5a9247e501 torrents: implement download button
Paper <paper@paper.us.eu.org>
parents: 100
diff changeset
25
2f5a9247e501 torrents: implement download button
Paper <paper@paper.us.eu.org>
parents: 100
diff changeset
26 protected:
2f5a9247e501 torrents: implement download button
Paper <paper@paper.us.eu.org>
parents: 100
diff changeset
27 void run() override {
2f5a9247e501 torrents: implement download button
Paper <paper@paper.us.eu.org>
parents: 100
diff changeset
28 emit ReceivedData(Get(url, headers));
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
2f5a9247e501 torrents: implement download button
Paper <paper@paper.us.eu.org>
parents: 100
diff changeset
31 std::string url;
2f5a9247e501 torrents: implement download button
Paper <paper@paper.us.eu.org>
parents: 100
diff changeset
32 std::vector<std::string> headers;
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
2f5a9247e501 torrents: implement download button
Paper <paper@paper.us.eu.org>
parents: 100
diff changeset
35 class PostThread : public QThread {
2f5a9247e501 torrents: implement download button
Paper <paper@paper.us.eu.org>
parents: 100
diff changeset
36 Q_OBJECT
2f5a9247e501 torrents: implement download button
Paper <paper@paper.us.eu.org>
parents: 100
diff changeset
37
2f5a9247e501 torrents: implement download button
Paper <paper@paper.us.eu.org>
parents: 100
diff changeset
38 public:
236
4d461ef7d424 HUGE UPDATE: convert build system to autotools
Paper <mrpapersonic@gmail.com>
parents: 230
diff changeset
39 PostThread(const std::string& u, const std::string& d, const std::vector<std::string>& h = {}, QObject* parent = nullptr) : QThread(parent) {
230
2f5a9247e501 torrents: implement download button
Paper <paper@paper.us.eu.org>
parents: 100
diff changeset
40 url = u;
2f5a9247e501 torrents: implement download button
Paper <paper@paper.us.eu.org>
parents: 100
diff changeset
41 data = d;
2f5a9247e501 torrents: implement download button
Paper <paper@paper.us.eu.org>
parents: 100
diff changeset
42 headers = h;
2f5a9247e501 torrents: implement download button
Paper <paper@paper.us.eu.org>
parents: 100
diff changeset
43 }
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 signals:
2f5a9247e501 torrents: implement download button
Paper <paper@paper.us.eu.org>
parents: 100
diff changeset
46 void ReceivedData(const QByteArray& ba);
2f5a9247e501 torrents: implement download button
Paper <paper@paper.us.eu.org>
parents: 100
diff changeset
47
2f5a9247e501 torrents: implement download button
Paper <paper@paper.us.eu.org>
parents: 100
diff changeset
48 protected:
2f5a9247e501 torrents: implement download button
Paper <paper@paper.us.eu.org>
parents: 100
diff changeset
49 void run() override {
2f5a9247e501 torrents: implement download button
Paper <paper@paper.us.eu.org>
parents: 100
diff changeset
50 emit ReceivedData(Post(url, data, headers));
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
2f5a9247e501 torrents: implement download button
Paper <paper@paper.us.eu.org>
parents: 100
diff changeset
53 std::string url;
2f5a9247e501 torrents: implement download button
Paper <paper@paper.us.eu.org>
parents: 100
diff changeset
54 std::string data;
2f5a9247e501 torrents: implement download button
Paper <paper@paper.us.eu.org>
parents: 100
diff changeset
55 std::vector<std::string> headers;
2f5a9247e501 torrents: implement download button
Paper <paper@paper.us.eu.org>
parents: 100
diff changeset
56 };
2f5a9247e501 torrents: implement download button
Paper <paper@paper.us.eu.org>
parents: 100
diff changeset
57
76
3364fadc8a36 *: format source code
Paper <mrpapersonic@gmail.com>
parents: 75
diff changeset
58 } // namespace HTTP
75
d3e9310598b1 *: refactor some stuff
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
59
d3e9310598b1 *: refactor some stuff
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
60 #endif // __core__http_h