/*
* HTTP through c8-base's curl runner: the request goes on curl's stdin,
* so the API key is never in the process list.
*/
#include <gio/gio.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <glib/gstdio.h>
#include "http.h"
#include "tiles.h"
static void run(const char *method, const char *url, const char *body,
const char *token, const char *dest, tm_http_fn fn, void *data) {
c8_http(&(struct c8_http){ .method = method, .url = url, .body = body,
.token = token, .dest = dest,
.accept = dest ? NULL : "application/json",
.agent = "c8-tiles/0.1 (cont8nuum)", .follow = true }, fn, data);
}
void tm_http_get(const char *url, const char *auth, tm_http_fn fn,
void *data) {
run("GET", url, NULL, auth, NULL, fn, data);
}
void tm_download(const char *url, const char *dest, tm_http_fn fn,
void *data) {
run("GET", url, NULL, NULL, dest, fn, data);
}