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
#ifndef HTTP_CLIENT_H
#define HTTP_CLIENT_H
#include <stddef.h>
typedef struct {
long status;
char *headers;
char *body;
} http_response;
void http_response_free(http_response *r);
/*
* Performs a simple HTTP request.
* - method: "GET", "HEAD", "POST"
* - url: http://host[:port]/path; for Unix socket, host is ignored but still required.
* - unix_socket: optional AF_UNIX socket path. If non-empty, connect to it instead of TCP.
* - extra_headers: raw CRLF-terminated headers, may be NULL.
* - body: optional request body, may be NULL.
*/
int http_request(const char *method, const char *url, const char *unix_socket,
const char *extra_headers, const char *body, http_response *out);
char *http_header_value(const char *headers, const char *name);
#endif