unsigned magic;
#define HTTP_MAGIC 0x6428b5c9
- struct ws ws[1];
+ struct ws *ws;
txt rx; /* Received Request */
txt pl; /* Pipelined bytes */
unsigned magic;
#define BEREQ_MAGIC 0x3b6d250c
VTAILQ_ENTRY(bereq) list;
- void *space;
- unsigned len;
+ struct ws ws[1];
struct http http[1];
};
unsigned xid;
struct objhead *objhead;
+ struct ws ws_o[1];
unsigned char *vary;
unsigned heap_idx;
/* HTTP request */
const char *doclose;
struct http *http;
+ struct ws ws[1];
/* Timestamps, all on TIM_real() timescale */
double t_open;
void http_PrintfHeader(struct worker *w, int fd, struct http *to, const char *fmt, ...);
void http_SetHeader(struct worker *w, int fd, struct http *to, const char *hdr);
void http_SetH(struct http *to, unsigned n, const char *fm);
-void http_Setup(struct http *ht, void *space, unsigned len);
+void http_Setup(struct http *ht, struct ws *ws);
int http_GetHdr(const struct http *hp, const char *hdr, char **ptr);
int http_GetHdrField(const struct http *hp, const char *hdr, const char *field, char **ptr);
int http_GetStatus(const struct http *hp);
int http_RecvHead(struct http *hp, int fd);
int http_DissectRequest(struct worker *w, struct http *sp, int fd);
int http_DissectResponse(struct worker *w, struct http *sp, int fd);
-void http_DoConnection(struct sess *sp);
+const char *http_DoConnection(struct http *hp);
void http_CopyHome(struct worker *w, int fd, struct http *hp);
void http_Unset(struct http *hp, const char *hdr);
if (bereq == NULL)
return (NULL);
bereq->magic = BEREQ_MAGIC;
- bereq->space = bereq + 1;
- bereq->len = len;
+ WS_Init(bereq->ws, bereq + 1, len);
}
- http_Setup(bereq->http, bereq->space, bereq->len);
+ http_Setup(bereq->http, bereq->ws);
return (bereq);
}
return (0);
}
- http_DoConnection(sp);
+ sp->doclose = http_DoConnection(sp->http);
/* By default we use the first backend */
AZ(sp->backend);
CHECK_OBJ_NOTNULL(sp->backend, BACKEND_MAGIC);
b = malloc(len);
AN(b);
- http_Setup(hp2, b, len);
+ WS_Init(sp->obj->ws_o, b, len);
+ http_Setup(hp2, sp->obj->ws_o);
CHECK_OBJ_NOTNULL(sp->backend, BACKEND_MAGIC);
hp2->logtag = HTTP_Obj;
/*--------------------------------------------------------------------*/
void
-http_Setup(struct http *hp, void *space, unsigned len)
+http_Setup(struct http *hp, struct ws *ws)
{
- assert(len > 0);
memset(hp, 0, sizeof *hp);
hp->magic = HTTP_MAGIC;
- WS_Init(hp->ws, space, len);
+ hp->ws = ws;
hp->nhd = HTTP_HDR_FIRST;
}
/*--------------------------------------------------------------------*/
-void
-http_DoConnection(struct sess *sp)
+const char *
+http_DoConnection(struct http *hp)
{
- struct http *hp = sp->http;
char *p, *q;
+ const char *ret;
unsigned u;
if (!http_GetHdr(hp, H_Connection, &p)) {
if (strcmp(hp->hd[HTTP_HDR_PROTO].b, "HTTP/1.1"))
- sp->doclose = "not HTTP/1.1";
- return;
+ return ("not HTTP/1.1");
+ return (NULL);
}
+ ret = NULL;
for (; *p; p++) {
if (isspace(*p))
continue;
break;
u = pdiff(p, q);
if (u == 5 && !strncasecmp(p, "close", u))
- sp->doclose = "Connection: close";
+ ret = "Connection: close";
u = http_findhdr(hp, u, p);
if (u != 0)
hp->hdf[u] |= HDF_FILTER;
break;
p = q;
}
+ return (ret);
}
/*--------------------------------------------------------------------*/
memset(sp, 0, sizeof *sp);
sp->magic = SESS_MAGIC;
sp->mem = sm;
- sp->http = &sm->http;
sp->sockaddr = (void*)(&sm->sockaddr[0]);
sp->sockaddrlen = sizeof(sm->sockaddr[0]);
sp->mysockaddr = (void*)(&sm->sockaddr[1]);
sp->sockaddrlen = len;
}
- http_Setup(&sm->http, (void *)(sm + 1), sm->workspace);
+ WS_Init(sp->ws, (void *)(sm + 1), sm->workspace);
+ sp->http = &sm->http;
+ http_Setup(sp->http, sp->ws);
return (sp);
}