[master] 8ebcfc4bb Inline RFC2616_Response_Body() in V1F, it is not transport agnostic.
Poul-Henning Kamp
phk at FreeBSD.org
Fri Feb 21 08:34:06 UTC 2020
commit 8ebcfc4bb27fda161fc26ca02638f26091c356fa
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Fri Feb 21 05:35:36 2020 +0000
Inline RFC2616_Response_Body() in V1F, it is not transport agnostic.
diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h
index 0d66cea58..e2274dd92 100644
--- a/bin/varnishd/cache/cache.h
+++ b/bin/varnishd/cache/cache.h
@@ -812,7 +812,6 @@ unsigned RFC2616_Req_Gzip(const struct http *);
int RFC2616_Do_Cond(const struct req *sp);
void RFC2616_Weaken_Etag(struct http *hp);
void RFC2616_Vary_AE(struct http *hp);
-void RFC2616_Response_Body(const struct worker *, const struct busyobj *);
/*
* A normal pointer difference is signed, but we never want a negative value
diff --git a/bin/varnishd/cache/cache_rfc2616.c b/bin/varnishd/cache/cache_rfc2616.c
index 77f30f92c..14e655c49 100644
--- a/bin/varnishd/cache/cache_rfc2616.c
+++ b/bin/varnishd/cache/cache_rfc2616.c
@@ -340,68 +340,3 @@ RFC2616_Vary_AE(struct http *hp)
http_SetHeader(hp, "Vary: Accept-Encoding");
}
}
-
-/*--------------------------------------------------------------------*/
-
-void
-RFC2616_Response_Body(const struct worker *wrk, const struct busyobj *bo)
-{
-
- CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
- CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
-
- /*
- * Figure out how the fetch is supposed to happen, before the
- * headers are adultered by VCL
- */
- if (!strcasecmp(http_GetMethod(bo->bereq), "head")) {
- /*
- * A HEAD request can never have a body in the reply,
- * no matter what the headers might say.
- * [RFC7231 4.3.2 p25]
- */
- wrk->stats->fetch_head++;
- bo->htc->body_status = BS_NONE;
- } else if (http_GetStatus(bo->beresp) <= 199) {
- /*
- * 1xx responses never have a body.
- * [RFC7230 3.3.2 p31]
- * ... but we should never see them.
- */
- wrk->stats->fetch_1xx++;
- bo->htc->body_status = BS_ERROR;
- } else if (http_IsStatus(bo->beresp, 204)) {
- /*
- * 204 is "No Content", obviously don't expect a body.
- * [RFC7230 3.3.1 p29 and 3.3.2 p31]
- */
- wrk->stats->fetch_204++;
- if ((http_GetHdr(bo->beresp, H_Content_Length, NULL) &&
- bo->htc->content_length != 0) ||
- http_GetHdr(bo->beresp, H_Transfer_Encoding, NULL))
- bo->htc->body_status = BS_ERROR;
- else
- bo->htc->body_status = BS_NONE;
- } else if (http_IsStatus(bo->beresp, 304)) {
- /*
- * 304 is "Not Modified" it has no body.
- * [RFC7230 3.3 p28]
- */
- wrk->stats->fetch_304++;
- bo->htc->body_status = BS_NONE;
- } else if (bo->htc->body_status == BS_CHUNKED) {
- wrk->stats->fetch_chunked++;
- } else if (bo->htc->body_status == BS_LENGTH) {
- assert(bo->htc->content_length > 0);
- wrk->stats->fetch_length++;
- } else if (bo->htc->body_status == BS_EOF) {
- wrk->stats->fetch_eof++;
- } else if (bo->htc->body_status == BS_ERROR) {
- wrk->stats->fetch_bad++;
- } else if (bo->htc->body_status == BS_NONE) {
- wrk->stats->fetch_none++;
- } else {
- WRONG("wrong bodystatus");
- }
-}
-
diff --git a/bin/varnishd/http1/cache_http1_fetch.c b/bin/varnishd/http1/cache_http1_fetch.c
index 075a412d6..4c5b593a1 100644
--- a/bin/varnishd/http1/cache_http1_fetch.c
+++ b/bin/varnishd/http1/cache_http1_fetch.c
@@ -237,7 +237,60 @@ V1F_FetchRespHdr(struct busyobj *bo)
}
htc->doclose = http_DoConnection(hp);
- RFC2616_Response_Body(bo->wrk, bo);
+
+ /*
+ * Figure out how the fetch is supposed to happen, before the
+ * headers are adultered by VCL
+ */
+ if (!strcasecmp(http_GetMethod(bo->bereq), "head")) {
+ /*
+ * A HEAD request can never have a body in the reply,
+ * no matter what the headers might say.
+ * [RFC7231 4.3.2 p25]
+ */
+ bo->wrk->stats->fetch_head++;
+ bo->htc->body_status = BS_NONE;
+ } else if (http_GetStatus(bo->beresp) <= 199) {
+ /*
+ * 1xx responses never have a body.
+ * [RFC7230 3.3.2 p31]
+ * ... but we should never see them.
+ */
+ bo->wrk->stats->fetch_1xx++;
+ bo->htc->body_status = BS_ERROR;
+ } else if (http_IsStatus(bo->beresp, 204)) {
+ /*
+ * 204 is "No Content", obviously don't expect a body.
+ * [RFC7230 3.3.1 p29 and 3.3.2 p31]
+ */
+ bo->wrk->stats->fetch_204++;
+ if ((http_GetHdr(bo->beresp, H_Content_Length, NULL) &&
+ bo->htc->content_length != 0) ||
+ http_GetHdr(bo->beresp, H_Transfer_Encoding, NULL))
+ bo->htc->body_status = BS_ERROR;
+ else
+ bo->htc->body_status = BS_NONE;
+ } else if (http_IsStatus(bo->beresp, 304)) {
+ /*
+ * 304 is "Not Modified" it has no body.
+ * [RFC7230 3.3 p28]
+ */
+ bo->wrk->stats->fetch_304++;
+ bo->htc->body_status = BS_NONE;
+ } else if (bo->htc->body_status == BS_CHUNKED) {
+ bo->wrk->stats->fetch_chunked++;
+ } else if (bo->htc->body_status == BS_LENGTH) {
+ assert(bo->htc->content_length > 0);
+ bo->wrk->stats->fetch_length++;
+ } else if (bo->htc->body_status == BS_EOF) {
+ bo->wrk->stats->fetch_eof++;
+ } else if (bo->htc->body_status == BS_ERROR) {
+ bo->wrk->stats->fetch_bad++;
+ } else if (bo->htc->body_status == BS_NONE) {
+ bo->wrk->stats->fetch_none++;
+ } else {
+ WRONG("wrong bodystatus");
+ }
assert(bo->vfc->resp == bo->beresp);
if (bo->htc->body_status != BS_NONE &&
More information about the varnish-commit
mailing list