Mercurial > minori
annotate include/core/http.h @ 258:862d0d8619f6
*: HUUUGE changes
animia has been renamed to animone, so instead of thinking of a
health condition, you think of a beautiful flower :)
I've also edited some of the code for animone, but I have no idea
if it even works or not because I don't have a mac or windows
machine lying around. whoops!
... anyway, all of the changes divergent from Anisthesia are now
licensed under BSD. it's possible that I could even rewrite most
of the code to where I don't even have to keep the MIT license,
but that's thinking too far into the future
I've been slacking off on implementing the anime seasons page,
mostly out of laziness. I think I'd have to create another db file
specifically for the seasons
anyway, this code is being pushed *primarily* because the hard drive
it's on is failing! yay :)
author | Paper <paper@paper.us.eu.org> |
---|---|
date | Mon, 01 Apr 2024 02:43:44 -0400 |
parents | 4d461ef7d424 |
children | 3ec7804abf17 |
rev | line source |
---|---|
75 | 1 #ifndef __core__http_h |
2 #define __core__http_h | |
3 | |
77 | 4 #include <QByteArray> |
230
2f5a9247e501
torrents: implement download button
Paper <paper@paper.us.eu.org>
parents:
100
diff
changeset
|
5 #include <QThread> |
75 | 6 #include <string> |
7 #include <vector> | |
8 | |
9 namespace HTTP { | |
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 | 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 | 18 GetThread(const std::string& u, const std::vector<std::string>& h = {}, QObject* parent = nullptr) |
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 | 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 | 38 PostThread(const std::string& u, const std::string& d, const std::vector<std::string>& h = {}, |
39 QObject* parent = nullptr) | |
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 | 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 | 57 } // namespace HTTP |
75 | 58 |
59 #endif // __core__http_h |