storeAppendPrintf(e, "Hdr Fields Parsed: %d\n", HeaderEntryParsedCount);
}
-// (ab)used by other modules.
-http_hdr_type
-httpHeaderIdByName(const char *name, size_t name_len, const HttpHeaderFieldInfo * info, int end)
-{
- if (name_len > 0) {
- for (int i = 0; i < end; ++i) {
- if (name_len != info[i].name.size())
- continue;
-
- if (!strncasecmp(name, info[i].name.rawBuf(), name_len))
- return info[i].id;
- }
- }
-
- return HDR_BAD_HDR;
-}
-
http_hdr_type
httpHeaderIdByNameDef(const SBuf &name)
{
hoEnd
} http_hdr_owner_type;
-class HttpHeaderFieldAttrs
-{
-public:
- HttpHeaderFieldAttrs() : name(NULL), id(HDR_BAD_HDR), type(field_type::ftInvalid) {}
- HttpHeaderFieldAttrs(const char *aName, http_hdr_type anId, field_type aType = field_type::ftInvalid) : name(aName), id(anId), type(aType) {}
-#if __cplusplus >= 201103L
- HttpHeaderFieldAttrs(const HttpHeaderFieldAttrs &) = default;
- HttpHeaderFieldAttrs(HttpHeaderFieldAttrs &&) = default;
-#endif
- // nothing to do as name is a pointer to global const string
- ~HttpHeaderFieldAttrs() {}
-
- const char *name;
- http_hdr_type id;
- field_type type;
-};
-
/** Iteration for headers; use HttpHeaderPos as opaque type, do not interpret */
typedef ssize_t HttpHeaderPos;
static void httpHeaderPutStrvf(HttpHeader * hdr, http_hdr_type id, const char *fmt, va_list vargs);
-HttpHeaderFieldInfo *
-httpHeaderBuildFieldsInfo(const HttpHeaderFieldAttrs * attrs, int count)
-{
- int i;
- HttpHeaderFieldInfo *table = NULL;
- assert(attrs && count);
-
- /* allocate space */
- table = new HttpHeaderFieldInfo[count];
-
- for (i = 0; i < count; ++i) {
- const http_hdr_type id = attrs[i].id;
- HttpHeaderFieldInfo *info = table + id;
- /* sanity checks */
- assert(id >= 0 && id < count);
- assert(attrs[i].name);
- assert(info->id == HDR_ACCEPT && info->type == field_type::ftInvalid); /* was not set before */
- /* copy and init fields */
- info->id = id;
- info->type = attrs[i].type;
- info->name = attrs[i].name;
- assert(info->name.size());
- }
-
- return table;
-}
-
-void
-httpHeaderDestroyFieldsInfo(HttpHeaderFieldInfo * table, int count)
-{
- int i;
-
- for (i = 0; i < count; ++i)
- table[i].name.clean();
-
- delete [] table;
-}
-
void
httpHeaderMaskInit(HttpHeaderMask * mask, int value)
{
int httpHeaderParseOffset(const char *start, int64_t * off);
-HttpHeaderFieldInfo *httpHeaderBuildFieldsInfo(const HttpHeaderFieldAttrs * attrs, int count);
-void httpHeaderDestroyFieldsInfo(HttpHeaderFieldInfo * info, int count);
-http_hdr_type httpHeaderIdByName(const char *name, size_t name_len, const HttpHeaderFieldInfo * attrs, int end);
http_hdr_type httpHeaderIdByNameDef(const SBuf &name);
http_hdr_type httpHeaderIdByNameDef(const char *name, int name_len);
int httpHeaderHasConnDir(const HttpHeader * hdr, const char *directive);