-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathlibicap.h
65 lines (51 loc) · 2.04 KB
/
libicap.h
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
#ifndef LIBICAP_H_
#define LIBICAP_H_
#include <stdint.h>
#ifdef _cplusplus
extern "C" {
#endif
#define IC_CODE_CONTINUE 100
#define IC_CODE_OK 200
#define IC_CODE_NO_CONTENT 204
#define IC_CODE_BAD_REQUEST 400
#define IC_CODE_NOT_FOUND 404
#define IC_CODE_REQ_TIMEOUT 408
typedef struct ic_query {
void *data;
} ic_query_t;
typedef enum ic_ctx_type {
IC_CTX_TYPE_CLOSE = 1, /* objects arriving using a TCP close */
IC_CTX_TYPE_CHUNKED, /* objects arriving using chunked encoding */
IC_CTX_TYPE_CL, /* objects arriving using "Content-Length" headers */
} ic_ctx_type_t;
int ic_query_init(ic_query_t *q);
int ic_connect(ic_query_t *q, const char *srv, uint16_t port);
int ic_get_options(ic_query_t *q, const char *service);
/** @return 0 if got respond, 1 if not all chunk data was send, < 0 if error */
int ic_send_respmod(ic_query_t *q);
int ic_send_reqmod(ic_query_t *q);
int ic_set_service(ic_query_t *q, const char *service);
int ic_set_req_hdr(ic_query_t *q, const unsigned char *hdr, size_t len, ic_ctx_type_t *type);
int ic_set_res_hdr(ic_query_t *q, const unsigned char *hdr, size_t len, ic_ctx_type_t *type);
int ic_allow_204(ic_query_t *q);
int ic_set_preview_len(ic_query_t *q, size_t len); /* defaults: 4096 */
int ic_set_stream_ended(ic_query_t *q);
/* body will not be copyed, do not free it before using ic_send_(resp|req)mod() */
int ic_set_body(ic_query_t *q, const unsigned char *body, size_t len);
int ic_reuse_connection(ic_query_t *q, int proceed);
void ic_disconnect(ic_query_t *q);
void ic_query_deinit(ic_query_t *q);
const char *ic_strerror(int err);
int ic_enable_debug(ic_query_t *q, const char *path);
int ic_get_status_code(ic_query_t *q);
const char *ic_get_icap_hdr(ic_query_t *q);
const char *ic_get_req_hdr(ic_query_t *q);
const char *ic_get_resp_hdr(ic_query_t *q);
/** @return -1 if ERROR */
int ic_get_content_len(ic_query_t *q, uint64_t *len);
/** @return NULL if ERROR */
const char *ic_get_content(ic_query_t *q, size_t *len, int *err);
#ifdef _cplusplus
}
#endif
#endif