aboutsummaryrefslogtreecommitdiff
path: root/src/Utility/HttpClient.h
blob: 5eceb83aed19ac290e534311b58813eded5db2ee (plain)
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
32
#ifndef HTTPCLIENT_H
#define HTTPCLIENT_H

#include <curl/curl.h>
#include <libxml/parser.h>
#include <stddef.h>
#include <time.h>

typedef struct {
  char *memory;
  size_t size;
  size_t capacity;
} HttpResponse;

HttpResponse http_get(const char *url, const char *user_agent);
void http_response_free(HttpResponse *resp);

typedef xmlDocPtr (*XmlParserFn)(const char *data, size_t size,
                                 const char *url);

typedef struct {
  char *memory;
  size_t size;
  void *parsed_result;
  int success;
} CachedHttpResponse;

CachedHttpResponse cached_http_get(const char *url, const char *user_agent,
                                   const char *cache_key, time_t cache_ttl,
                                   XmlParserFn parser);

#endif