1 #ifndef HTTP_HEADER_H
2 #define HTTP_HEADER_H
3
4 struct http_header;
5
6 struct http_header_limits {
7 uoff_t max_size;
8 uoff_t max_field_size;
9 unsigned int max_fields;
10 };
11
12 struct http_header_field {
13 const char *name;
14 const char *value;
15 size_t size;
16 };
17 ARRAY_DEFINE_TYPE(http_header_field, struct http_header_field);
18
http_header_field_is(const struct http_header_field * hfield,const char * name)19 static inline bool http_header_field_is(const struct http_header_field *hfield,
20 const char *name)
21 {
22 return (strcasecmp(hfield->name, name) == 0);
23 }
24
25 struct http_header *
26 http_header_create(pool_t pool, unsigned int init_count);
27
28 const struct http_header_field *
29 http_header_field_add(struct http_header *header,
30 const char *name, const unsigned char *data, size_t size);
31 void http_header_field_delete(struct http_header *header, const char *name);
32
33 const ARRAY_TYPE(http_header_field) *
34 http_header_get_fields(const struct http_header *header) ATTR_PURE;
35
36 const struct http_header_field *
37 http_header_field_find(const struct http_header *header, const char *name)
38 ATTR_PURE;
39 const char *
40 http_header_field_get(const struct http_header *header, const char *name)
41 ATTR_PURE;
42 int http_header_field_find_unique(const struct http_header *header,
43 const char *name, const struct http_header_field **hfield_r);
44
45 #endif
46