summaryrefslogtreecommitdiffstats
path: root/include/haproxy/http_client.h
blob: 241ca24ce732a0db06c7dc338c648bd204c80df5 (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
33
34
35
36
37
38
39
40
#ifndef _HAPROXY_HTTPCLIENT_H
#define _HAPROXY_HTTPCLIENT_H

#include <haproxy/http_client-t.h>

void httpclient_destroy(struct httpclient *hc);
void httpclient_stop_and_destroy(struct httpclient *hc);

struct proxy *httpclient_create_proxy(const char *id);
struct httpclient *httpclient_new(void *caller, enum http_meth_t meth, struct ist url);
struct httpclient *httpclient_new_from_proxy(struct proxy *px, void *caller, enum http_meth_t meth, struct ist url);
int httpclient_set_proxy(struct httpclient *hc, struct proxy *px);

struct appctx *httpclient_start(struct httpclient *hc);
int httpclient_set_dst(struct httpclient *hc, const char *dst);
void httpclient_set_timeout(struct httpclient *hc, int timeout);
int httpclient_res_xfer(struct httpclient *hc, struct buffer *dst);
int httpclient_req_gen(struct httpclient *hc, const struct ist url, enum http_meth_t meth, const struct http_hdr *hdrs, const struct ist payload);
int httpclient_req_xfer(struct httpclient *hc, struct ist src, int end);

/* Return the amount of data available in the httpclient response buffer */
static inline int httpclient_data(struct httpclient *hc)
{
	return b_data(&hc->res.buf);
}

/* Return 1 if the httpclient ended and won't receive any new data */
static inline int httpclient_ended(struct httpclient *hc)
{
	return !!(hc->flags & HTTPCLIENT_FS_ENDED);
}

/* Return 1 if the httpclient started */
static inline int httpclient_started(struct httpclient *hc)
{

	return !!(hc->flags & HTTPCLIENT_FS_STARTED);
}

#endif /* ! _HAPROXY_HTTCLIENT_H */