e8f1e510df3ab051a816715c2056f0d10aee929eStephan Bosch#ifndef HTTP_HEADER_H
e8f1e510df3ab051a816715c2056f0d10aee929eStephan Bosch#define HTTP_HEADER_H
e8f1e510df3ab051a816715c2056f0d10aee929eStephan Bosch
e8f1e510df3ab051a816715c2056f0d10aee929eStephan Boschstruct http_header;
e8f1e510df3ab051a816715c2056f0d10aee929eStephan Bosch
feba5e502b2131c9a1c766b7ef9ff041dbf71d1dStephan Boschstruct http_header_limits {
feba5e502b2131c9a1c766b7ef9ff041dbf71d1dStephan Bosch uoff_t max_size;
feba5e502b2131c9a1c766b7ef9ff041dbf71d1dStephan Bosch uoff_t max_field_size;
feba5e502b2131c9a1c766b7ef9ff041dbf71d1dStephan Bosch unsigned int max_fields;
feba5e502b2131c9a1c766b7ef9ff041dbf71d1dStephan Bosch};
feba5e502b2131c9a1c766b7ef9ff041dbf71d1dStephan Bosch
e8f1e510df3ab051a816715c2056f0d10aee929eStephan Boschstruct http_header_field {
28f18734bd5be3122994f5d85b5a8287e1d9f272Martti Rannanjärvi const char *name;
e8f1e510df3ab051a816715c2056f0d10aee929eStephan Bosch const char *value;
e8f1e510df3ab051a816715c2056f0d10aee929eStephan Bosch size_t size;
e8f1e510df3ab051a816715c2056f0d10aee929eStephan Bosch};
e8f1e510df3ab051a816715c2056f0d10aee929eStephan BoschARRAY_DEFINE_TYPE(http_header_field, struct http_header_field);
e8f1e510df3ab051a816715c2056f0d10aee929eStephan Bosch
e8f1e510df3ab051a816715c2056f0d10aee929eStephan Boschstatic inline bool http_header_field_is(const struct http_header_field *hfield,
e8f1e510df3ab051a816715c2056f0d10aee929eStephan Bosch const char *name)
e8f1e510df3ab051a816715c2056f0d10aee929eStephan Bosch{
28f18734bd5be3122994f5d85b5a8287e1d9f272Martti Rannanjärvi return (strcasecmp(hfield->name, name) == 0);
e8f1e510df3ab051a816715c2056f0d10aee929eStephan Bosch}
e8f1e510df3ab051a816715c2056f0d10aee929eStephan Bosch
e8f1e510df3ab051a816715c2056f0d10aee929eStephan Boschstruct http_header *
e8f1e510df3ab051a816715c2056f0d10aee929eStephan Boschhttp_header_create(pool_t pool, unsigned int init_count);
e8f1e510df3ab051a816715c2056f0d10aee929eStephan Bosch
e8f1e510df3ab051a816715c2056f0d10aee929eStephan Boschconst struct http_header_field *
e8f1e510df3ab051a816715c2056f0d10aee929eStephan Boschhttp_header_field_add(struct http_header *header,
e8f1e510df3ab051a816715c2056f0d10aee929eStephan Bosch const char *name, const unsigned char *data, size_t size);
e8f1e510df3ab051a816715c2056f0d10aee929eStephan Boschvoid http_header_field_delete(struct http_header *header, const char *name);
e8f1e510df3ab051a816715c2056f0d10aee929eStephan Bosch
e8f1e510df3ab051a816715c2056f0d10aee929eStephan Boschconst ARRAY_TYPE(http_header_field) *
e8f1e510df3ab051a816715c2056f0d10aee929eStephan Boschhttp_header_get_fields(const struct http_header *header) ATTR_PURE;
e8f1e510df3ab051a816715c2056f0d10aee929eStephan Bosch
e8f1e510df3ab051a816715c2056f0d10aee929eStephan Boschconst struct http_header_field *
e8f1e510df3ab051a816715c2056f0d10aee929eStephan Boschhttp_header_field_find(const struct http_header *header, const char *name)
e8f1e510df3ab051a816715c2056f0d10aee929eStephan Bosch ATTR_PURE;
e8f1e510df3ab051a816715c2056f0d10aee929eStephan Boschconst char *
e8f1e510df3ab051a816715c2056f0d10aee929eStephan Boschhttp_header_field_get(const struct http_header *header, const char *name)
e8f1e510df3ab051a816715c2056f0d10aee929eStephan Bosch ATTR_PURE;
e8f1e510df3ab051a816715c2056f0d10aee929eStephan Boschint http_header_field_find_unique(const struct http_header *header,
9229d5ecc3ebaa38f102eb9e16808bcc7e37c91dTimo Sirainen const char *name, const struct http_header_field **hfield_r);
e8f1e510df3ab051a816715c2056f0d10aee929eStephan Bosch
e8f1e510df3ab051a816715c2056f0d10aee929eStephan Bosch#endif