Commit c94a4271 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Move http_Write() to HTTP1_Write(). The name is still not really

good, but at least it belongs here.
parent 2bbb032b
......@@ -851,7 +851,6 @@ const char *http_StatusMessage(unsigned);
unsigned http_EstimateWS(const struct http *fm, unsigned how, uint16_t *nhd);
void HTTP_Init(void);
void http_ClrHeader(struct http *to);
unsigned http_Write(const struct worker *w, const struct http *hp, int resp);
void http_SetResp(struct http *to, const char *proto, uint16_t status,
const char *response);
void http_FilterReq(const struct req *, unsigned how);
......@@ -899,6 +898,7 @@ ssize_t HTTP1_Read(struct http_conn *htc, void *d, size_t len);
enum htc_status_e HTTP1_Complete(struct http_conn *htc);
uint16_t HTTP1_DissectRequest(struct req *);
uint16_t HTTP1_DissectResponse(struct http *sp, const struct http_conn *htc);
unsigned HTTP1_Write(const struct worker *w, const struct http *hp, int resp);
#define HTTPH(a, b, c) extern char b[];
#include "tbl/http_headers.h"
......
......@@ -402,7 +402,7 @@ FetchHdr(struct req *req, int need_host_hdr, int sendbody)
(void)VTCP_blocking(vc->fd); /* XXX: we should timeout instead */
WRW_Reserve(wrk, &vc->fd, bo->vsl, req->t_req); /* XXX t_resp ? */
(void)http_Write(wrk, hp, 0); /* XXX: stats ? */
(void)HTTP1_Write(wrk, hp, 0); /* XXX: stats ? */
/* Deal with any message-body the request might (still) have */
i = 0;
......
......@@ -793,49 +793,6 @@ HTTP_Copy(struct http *to, const struct http * const fm)
/*--------------------------------------------------------------------*/
unsigned
http_Write(const struct worker *w, const struct http *hp, int resp)
{
unsigned u, l;
if (resp) {
l = WRW_WriteH(w, &hp->hd[HTTP_HDR_PROTO], " ");
http_VSLH(hp, HTTP_HDR_PROTO);
hp->hd[HTTP_HDR_STATUS].b = WS_Alloc(hp->ws, 4);
AN(hp->hd[HTTP_HDR_STATUS].b);
sprintf(hp->hd[HTTP_HDR_STATUS].b, "%3d", hp->status);
hp->hd[HTTP_HDR_STATUS].e = hp->hd[HTTP_HDR_STATUS].b + 3;
l += WRW_WriteH(w, &hp->hd[HTTP_HDR_STATUS], " ");
http_VSLH(hp, HTTP_HDR_STATUS);
l += WRW_WriteH(w, &hp->hd[HTTP_HDR_RESPONSE], "\r\n");
http_VSLH(hp, HTTP_HDR_RESPONSE);
} else {
AN(hp->hd[HTTP_HDR_URL].b);
l = WRW_WriteH(w, &hp->hd[HTTP_HDR_METHOD], " ");
http_VSLH(hp, HTTP_HDR_METHOD);
l += WRW_WriteH(w, &hp->hd[HTTP_HDR_URL], " ");
http_VSLH(hp, HTTP_HDR_URL);
l += WRW_WriteH(w, &hp->hd[HTTP_HDR_PROTO], "\r\n");
http_VSLH(hp, HTTP_HDR_PROTO);
}
for (u = HTTP_HDR_FIRST; u < hp->nhd; u++) {
if (hp->hd[u].b == NULL)
continue;
AN(hp->hd[u].b);
AN(hp->hd[u].e);
l += WRW_WriteH(w, &hp->hd[u], "\r\n");
http_VSLH(hp, u);
}
l += WRW_Write(w, "\r\n", -1);
return (l);
}
/*--------------------------------------------------------------------*/
void
HTTP_Init(void)
{
......
......@@ -482,3 +482,46 @@ HTTP1_DissectResponse(struct http *hp, const struct http_conn *htc)
return (retval);
}
/*--------------------------------------------------------------------*/
unsigned
HTTP1_Write(const struct worker *w, const struct http *hp, int resp)
{
unsigned u, l;
if (resp) {
l = WRW_WriteH(w, &hp->hd[HTTP_HDR_PROTO], " ");
http_VSLH(hp, HTTP_HDR_PROTO);
hp->hd[HTTP_HDR_STATUS].b = WS_Alloc(hp->ws, 4);
AN(hp->hd[HTTP_HDR_STATUS].b);
sprintf(hp->hd[HTTP_HDR_STATUS].b, "%3d", hp->status);
hp->hd[HTTP_HDR_STATUS].e = hp->hd[HTTP_HDR_STATUS].b + 3;
l += WRW_WriteH(w, &hp->hd[HTTP_HDR_STATUS], " ");
http_VSLH(hp, HTTP_HDR_STATUS);
l += WRW_WriteH(w, &hp->hd[HTTP_HDR_RESPONSE], "\r\n");
http_VSLH(hp, HTTP_HDR_RESPONSE);
} else {
AN(hp->hd[HTTP_HDR_URL].b);
l = WRW_WriteH(w, &hp->hd[HTTP_HDR_METHOD], " ");
http_VSLH(hp, HTTP_HDR_METHOD);
l += WRW_WriteH(w, &hp->hd[HTTP_HDR_URL], " ");
http_VSLH(hp, HTTP_HDR_URL);
l += WRW_WriteH(w, &hp->hd[HTTP_HDR_PROTO], "\r\n");
http_VSLH(hp, HTTP_HDR_PROTO);
}
for (u = HTTP_HDR_FIRST; u < hp->nhd; u++) {
if (hp->hd[u].b == NULL)
continue;
AN(hp->hd[u].b);
AN(hp->hd[u].e);
l += WRW_WriteH(w, &hp->hd[u], "\r\n");
http_VSLH(hp, u);
}
l += WRW_Write(w, "\r\n", -1);
return (l);
}
......@@ -82,7 +82,7 @@ PipeRequest(struct req *req)
(void)VTCP_blocking(vc->fd);
WRW_Reserve(wrk, &vc->fd, bo->vsl, req->t_req);
req->acct_req.hdrbytes += http_Write(wrk, bo->bereq, 0);
req->acct_req.hdrbytes += HTTP1_Write(wrk, bo->bereq, 0);
if (req->htc->pipeline.b != NULL)
req->acct_req.bodybytes +=
......
......@@ -260,7 +260,7 @@ RES_WriteObj(struct req *req)
*/
if (!(req->res_mode & RES_ESI_CHILD))
req->acct_req.hdrbytes +=
http_Write(req->wrk, req->resp, 1);
HTTP1_Write(req->wrk, req->resp, 1);
if (!req->wantbody)
req->res_mode &= ~RES_CHUNKED;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment