Mercurial > minori
comparison src/core/http.cc @ 202:71832ffe425a
animia: re-add kvm fd source
this is all being merged from my wildly out-of-date laptop. SORRY!
in other news, I edited the CI file to install the wayland client
as well, so the linux CI build might finally get wayland stuff.
| author | Paper <paper@paper.us.eu.org> |
|---|---|
| date | Tue, 02 Jan 2024 06:05:06 -0500 |
| parents | 9b10175be389 |
| children | 53211cb1e7f5 |
comparison
equal
deleted
inserted
replaced
| 201:8f6f8dd2eb23 | 202:71832ffe425a |
|---|---|
| 1 #include "core/http.h" | 1 #include "core/http.h" |
| 2 #include "core/session.h" | 2 #include "core/session.h" |
| 3 #include <QByteArray> | 3 #include <QByteArray> |
| 4 #include <QMessageBox> | |
| 5 #include <curl/curl.h> | 4 #include <curl/curl.h> |
| 6 #include <string> | 5 #include <string> |
| 7 #include <vector> | 6 #include <vector> |
| 7 #include <iostream> | |
| 8 | 8 |
| 9 namespace HTTP { | 9 namespace HTTP { |
| 10 | 10 |
| 11 static size_t WriteCallback(void* contents, size_t size, size_t nmemb, void* userdata) { | 11 static size_t WriteCallback(void* contents, size_t size, size_t nmemb, void* userdata) { |
| 12 reinterpret_cast<QByteArray*>(userdata)->append(reinterpret_cast<char*>(contents), size * nmemb); | 12 reinterpret_cast<QByteArray*>(userdata)->append(reinterpret_cast<char*>(contents), size * nmemb); |
| 29 /* Use system certs... useful on Windows. */ | 29 /* Use system certs... useful on Windows. */ |
| 30 curl_easy_setopt(curl, CURLOPT_SSL_OPTIONS, CURLSSLOPT_NATIVE_CA); | 30 curl_easy_setopt(curl, CURLOPT_SSL_OPTIONS, CURLSSLOPT_NATIVE_CA); |
| 31 CURLcode res = curl_easy_perform(curl); | 31 CURLcode res = curl_easy_perform(curl); |
| 32 session.IncrementRequests(); | 32 session.IncrementRequests(); |
| 33 curl_easy_cleanup(curl); | 33 curl_easy_cleanup(curl); |
| 34 if (res != CURLE_OK) { | 34 if (res != CURLE_OK) |
| 35 QMessageBox box(QMessageBox::Icon::Critical, "", | 35 std::cerr << "curl_easy_perform(curl) failed!: " << curl_easy_strerror(res) << std::endl; |
| 36 QString("curl_easy_perform(curl) failed!: ") + QString(curl_easy_strerror(res))); | |
| 37 box.exec(); | |
| 38 } | |
| 39 } | 36 } |
| 40 return userdata; | 37 return userdata; |
| 41 } | 38 } |
| 42 | 39 |
| 43 QByteArray Post(const std::string& url, const std::string& data, const std::vector<std::string>& headers) { | 40 QByteArray Post(const std::string& url, const std::string& data, const std::vector<std::string>& headers) { |
| 57 /* Use system certs... useful on Windows. */ | 54 /* Use system certs... useful on Windows. */ |
| 58 curl_easy_setopt(curl, CURLOPT_SSL_OPTIONS, CURLSSLOPT_NATIVE_CA); | 55 curl_easy_setopt(curl, CURLOPT_SSL_OPTIONS, CURLSSLOPT_NATIVE_CA); |
| 59 CURLcode res = curl_easy_perform(curl); | 56 CURLcode res = curl_easy_perform(curl); |
| 60 session.IncrementRequests(); | 57 session.IncrementRequests(); |
| 61 curl_easy_cleanup(curl); | 58 curl_easy_cleanup(curl); |
| 62 if (res != CURLE_OK) { | 59 if (res != CURLE_OK) |
| 63 QMessageBox box(QMessageBox::Icon::Critical, "", | 60 std::cerr << "curl_easy_perform(curl) failed!: " << curl_easy_strerror(res) << std::endl; |
| 64 QString("curl_easy_perform(curl) failed!: ") + QString(curl_easy_strerror(res))); | |
| 65 box.exec(); | |
| 66 } | |
| 67 } | 61 } |
| 68 return userdata; | 62 return userdata; |
| 69 } | 63 } |
| 70 | 64 |
| 71 } // namespace HTTP | 65 } // namespace HTTP |
