summaryrefslogtreecommitdiffstats
path: root/include/haproxy/http_client-t.h
blob: 7ae0e612f0b5f5ab1ca42a4ba7f52c4b795648da (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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#ifndef _HAPROXY_HTTPCLIENT_T_H
#define _HAPROXY_HTTPCLIENT_T_H

#include <haproxy/http-t.h>

struct httpclient {
	struct {
		struct ist url;                /* URL of the request */
		enum http_meth_t meth;       /* method of the request */
		struct buffer buf;             /* output buffer, HTX */
	} req;
	struct {
		struct ist vsn;
		uint16_t status;
		struct ist reason;
		struct http_hdr *hdrs;         /* headers */
		struct buffer buf;             /* input buffer, raw HTTP */
	} res;
	struct {
               /* callbacks used to send the request, */
		void (*req_payload)(struct httpclient *hc);          /* send a payload */

		/* callbacks used to receive the response, if not set, the IO
		 * handler will consume the data without doing anything */
		void (*res_stline)(struct httpclient *hc);          /* start line received */
		void (*res_headers)(struct httpclient *hc);         /* headers received */
		void (*res_payload)(struct httpclient *hc);         /* payload received */
		void (*res_end)(struct httpclient *hc);             /* end of the response */
	} ops;
	struct sockaddr_storage *dst;         /* destination address */
	struct appctx *appctx;                /* HTTPclient appctx */
	int timeout_server;                   /* server timeout in ms */
	void *caller;                         /* ptr of the caller */
	unsigned int flags;                   /* other flags */
	struct proxy *px;                     /* proxy for special cases */
	struct server *srv_raw;               /* server for clear connections */
#ifdef USE_OPENSSL
	struct server *srv_ssl;               /* server for SSL connections */
#endif
};

/* Action (FA) to do */
#define    HTTPCLIENT_FA_STOP         0x00000001   /* stops the httpclient at the next IO handler call */
#define    HTTPCLIENT_FA_AUTOKILL     0x00000002   /* sets the applet to destroy the httpclient struct itself */

/* status (FS) */
#define    HTTPCLIENT_FS_STARTED      0x00010000 /* the httpclient was started */
#define    HTTPCLIENT_FS_ENDED        0x00020000 /* the httpclient is stopped */

/* States of the HTTP Client Appctx */
enum {
	HTTPCLIENT_S_REQ = 0,
	HTTPCLIENT_S_REQ_BODY,
	HTTPCLIENT_S_RES_STLINE,
	HTTPCLIENT_S_RES_HDR,
	HTTPCLIENT_S_RES_BODY,
	HTTPCLIENT_S_RES_END,
};

#define HTTPCLIENT_USERAGENT "HAProxy"

/* What kind of data we need to read */
#define HC_F_RES_STLINE     0x01
#define HC_F_RES_HDR        0x02
#define HC_F_RES_BODY       0x04
#define HC_F_RES_END        0x08


#endif /* ! _HAPROXY_HTTCLIENT__T_H */