#include "common.h"
#include "miniobj.h"
-#define MAX_HTTP_HDRS 32
-
-#define MAX_IOVS (MAX_HTTP_HDRS * 2)
+enum {
+ HTTP_HDR_REQ,
+ HTTP_HDR_URL,
+ HTTP_HDR_PROTO,
+ HTTP_HDR_STATUS,
+ HTTP_HDR_RESPONSE,
+ /* add more here */
+ HTTP_HDR_FIRST,
+ HTTP_HDR_MAX = 32
+};
-#define HTTP_HDR_REQ 0
-#define HTTP_HDR_URL 1
-#define HTTP_HDR_PROTO 2
-#define HTTP_HDR_STATUS 3
-#define HTTP_HDR_RESPONSE 4
-#define HTTP_HDR_FIRST 5
+#define MAX_IOVS (HTTP_HDR_MAX * 2)
struct cli;
struct vsb;
HTTP_Obj
} logtag;
- struct http_hdr hd[MAX_HTTP_HDRS];
+ struct http_hdr hd[HTTP_HDR_MAX];
unsigned nhd;
};
p[2] == '-')
hp->conds = 1;
- if (hp->nhd < MAX_HTTP_HDRS) {
+ if (hp->nhd < HTTP_HDR_MAX) {
hp->hd[hp->nhd].b = p;
hp->hd[hp->nhd].e = q;
VSLH(HTTP_T_Header, fd, hp, hp->nhd);
static void
http_seth(int fd, struct http *to, unsigned n, enum httptag tag, const char *fm)
{
- assert(n < MAX_HTTP_HDRS);
+ assert(n < HTTP_HDR_MAX);
assert(fm != NULL);
to->hd[n].b = (void*)(uintptr_t)fm;
to->hd[n].e = (void*)(uintptr_t)strchr(fm, '\0');
http_copyh(int fd, struct http *to, struct http *fm, unsigned n, enum httptag tag)
{
- assert(n < MAX_HTTP_HDRS);
+ assert(n < HTTP_HDR_MAX);
assert(fm->hd[n].b != NULL);
to->hd[n].b = fm->hd[n].b;
to->hd[n].e = fm->hd[n].e;
CHECK_OBJ_NOTNULL(fm, HTTP_MAGIC);
CHECK_OBJ_NOTNULL(to, HTTP_MAGIC);
- assert(n < MAX_HTTP_HDRS);
+ assert(n < HTTP_HDR_MAX);
assert(fm->hd[n].b != NULL);
- if (to->nhd < MAX_HTTP_HDRS) {
+ if (to->nhd < HTTP_HDR_MAX) {
to->hd[to->nhd].b = fm->hd[n].b;
to->hd[to->nhd].e = fm->hd[n].e;
VSLH(HTTP_T_Header, fd, to, to->nhd);
{
CHECK_OBJ_NOTNULL(to, HTTP_MAGIC);
- if (to->nhd >= MAX_HTTP_HDRS) {
+ if (to->nhd >= HTTP_HDR_MAX) {
VSL_stats->losthdr++;
VSL(T(to, HTTP_T_LostHeader), fd, "%s", hdr);
return;
va_start(ap, fmt);
l = to->e - to->f;
n = vsnprintf(to->f, l, fmt, ap);
- if (n + 1 > l || to->nhd >= MAX_HTTP_HDRS) {
+ if (n + 1 > l || to->nhd >= HTTP_HDR_MAX) {
VSL_stats->losthdr++;
VSL(T(to, HTTP_T_LostHeader), fd, "%s", to->f);
} else {