[master] c94a427 Move http_Write() to HTTP1_Write(). The name is still not really good, but at least it belongs here.

Poul-Henning Kamp phk at varnish-cache.org
Wed Jan 30 11:14:49 CET 2013


commit c94a427138d2d2e45c48589bf137c4a38b46cc61
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Wed Jan 30 10:14:27 2013 +0000

    Move http_Write() to HTTP1_Write().  The name is still not really
    good, but at least it belongs here.

diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h
index f5ebf7a..6be2c73 100644
--- a/bin/varnishd/cache/cache.h
+++ b/bin/varnishd/cache/cache.h
@@ -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"
diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c
index e64730b..f4befdf 100644
--- a/bin/varnishd/cache/cache_fetch.c
+++ b/bin/varnishd/cache/cache_fetch.c
@@ -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;
diff --git a/bin/varnishd/cache/cache_http.c b/bin/varnishd/cache/cache_http.c
index c46cb15..e9f9e22 100644
--- a/bin/varnishd/cache/cache_http.c
+++ b/bin/varnishd/cache/cache_http.c
@@ -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)
 {
diff --git a/bin/varnishd/cache/cache_http1_proto.c b/bin/varnishd/cache/cache_http1_proto.c
index e0c8b83..00ed9bf 100644
--- a/bin/varnishd/cache/cache_http1_proto.c
+++ b/bin/varnishd/cache/cache_http1_proto.c
@@ -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);
+}
+
diff --git a/bin/varnishd/cache/cache_pipe.c b/bin/varnishd/cache/cache_pipe.c
index f13bbcc..36c48ad 100644
--- a/bin/varnishd/cache/cache_pipe.c
+++ b/bin/varnishd/cache/cache_pipe.c
@@ -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 +=
diff --git a/bin/varnishd/cache/cache_response.c b/bin/varnishd/cache/cache_response.c
index 3fecd27..b49f405 100644
--- a/bin/varnishd/cache/cache_response.c
+++ b/bin/varnishd/cache/cache_response.c
@@ -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;



More information about the varnish-commit mailing list