~kris/hacks

sbot

ref: a6258c0c45f7c5d08ff77d4bcf9d747a24199a15 sbot/fetch.h -rw-r--r-- 644 bytes
a6258c0c — Kris Yotam update sbot 6 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/* See LICENSE file for copyright and license details. */

#ifndef FETCH_H
#define FETCH_H

#include <stddef.h>

/* Retry settings */
#define FETCH_MAX_RETRIES  3
#define FETCH_RETRY_BASE   2  /* base seconds for exponential backoff */

/* Response structure */
typedef struct {
	char *data;
	size_t size;
	char *content_type;
	long status_code;
	char *final_url;
} Response;

/* Initialize/cleanup curl globally */
void fetch_init(void);
void fetch_cleanup(void);

/* Fetch a URL with automatic retry on transient errors */
Response *fetch_url(const char *url);

/* Free a response */
void response_free(Response *resp);

#endif /* FETCH_H */