summaryrefslogtreecommitdiff
path: root/src/http.c
diff options
context:
space:
mode:
authornirav <nirav@teisuu.com>2019-03-21 16:34:24 +0530
committerDandelion <nirav@teisuu.com>2019-03-21 16:50:20 +0530
commit4b27c1a348d8de036dabd5525452f5b9ad08a32b (patch)
treef70c35351dc357d4297f985607fce9221ced96f0 /src/http.c
parentc608bcc3dfab2abe7b66c10f8556086b2d45b3a3 (diff)
downloadap_client-4b27c1a348d8de036dabd5525452f5b9ad08a32b.tar.gz
ap_client-4b27c1a348d8de036dabd5525452f5b9ad08a32b.zip
Use g_threads, add builder ui for timeline
Diffstat (limited to 'src/http.c')
-rw-r--r--src/http.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/http.c b/src/http.c
index 96a723d..84b62be 100644
--- a/src/http.c
+++ b/src/http.c
@@ -6,6 +6,7 @@
#include <curl/curl.h>
#include "string-util.h"
#include "auth.h"
+#include "config.h"
#include "log.h"
#define BUFFER_SIZE (256 * 1024)
@@ -13,7 +14,11 @@
int http_init()
{
- return curl_global_init(CURL_GLOBAL_ALL);
+ if (curl_global_init(CURL_GLOBAL_ALL)) {
+ log_msg(LOG_WARNING, "http_init", "failed to init curl");
+ return -1;
+ }
+ return 0;
}
void http_cleanup()
@@ -44,7 +49,6 @@ static size_t write_response(void *ptr, size_t size, size_t nmemb, void *stream)
char *get_request(const char *url)
{
-
CURL *curl = NULL;
CURLcode status;
struct curl_slist *headers = NULL;
@@ -61,6 +65,8 @@ char *get_request(const char *url)
struct write_result write_result = {.data = data, .pos = 0};
+ log_msg(LOG_INFO, "get_request", "loggedid: %d, token: %s", is_logged_in(), get_access_token());
+
if (is_logged_in()) {
const char *token = get_access_token();
size_t s = strlen(AUTH_HEADER_STR_PREFIX) + strlen(token) + 1;
@@ -76,7 +82,7 @@ char *get_request(const char *url)
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &write_result);
status = curl_easy_perform(curl);
- if (status != 0) {
+ if (status) {
log_msg(LOG_WARNING, "get_request",
"unable to request data from %s: %s", url,
curl_easy_strerror(status));
@@ -145,7 +151,7 @@ char *post_request(const char *url, char *post_data)
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, post_data);
status = curl_easy_perform(curl);
- if (status != 0) {
+ if (status) {
log_msg(LOG_WARNING, "post_request", "unable to request data from %s: %s",
url, curl_easy_strerror(status));
goto error;