I found myself needing this for a vmod.
OK?
From d88cb50a810372f7119f9ae98b95ecd668b4478c Mon Sep 17 00:00:00 2001
From: "Federico G. Schwindt" <[email protected]>
Date: Thu, 27 Nov 2014 18:42:39 +0000
Subject: [PATCH] Make vrt_selecthttp public
---
bin/varnishd/cache/cache_vrt.c | 10 +++++-----
include/vrt.h | 1 +
lib/libvmod_std/vmod_std.c | 11 +++--------
3 files changed, 9 insertions(+), 13 deletions(-)
diff --git a/bin/varnishd/cache/cache_vrt.c b/bin/varnishd/cache/cache_vrt.c
index a49da52..5fbf923 100644
--- a/bin/varnishd/cache/cache_vrt.c
+++ b/bin/varnishd/cache/cache_vrt.c
@@ -90,8 +90,8 @@ VRT_acl_log(VRT_CTX, const char *msg)
/*--------------------------------------------------------------------*/
-static struct http *
-vrt_selecthttp(VRT_CTX, enum gethdr_e where)
+struct http *
+VRT_selecthttp(VRT_CTX, enum gethdr_e where)
{
struct http *hp;
@@ -110,7 +110,7 @@ vrt_selecthttp(VRT_CTX, enum gethdr_e where)
hp = ctx->http_resp;
break;
default:
- WRONG("vrt_selecthttp 'where' invalid");
+ WRONG("VRT_selecthttp 'where' invalid");
}
return (hp);
}
@@ -130,7 +130,7 @@ VRT_GetHdr(VRT_CTX, const struct gethdr_s *hs)
return(HTTP_GetHdrPack(ctx->req->wrk, ctx->req->objcore,
hs->what));
}
- hp = vrt_selecthttp(ctx, hs->where);
+ hp = VRT_selecthttp(ctx, hs->where);
CHECK_OBJ_NOTNULL(hp, HTTP_MAGIC);
if (!http_GetHdr(hp, hs->what, &p))
return (NULL);
@@ -228,7 +228,7 @@ VRT_SetHdr(VRT_CTX , const struct gethdr_s *hs,
CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
AN(hs);
AN(hs->what);
- hp = vrt_selecthttp(ctx, hs->where);
+ hp = VRT_selecthttp(ctx, hs->where);
CHECK_OBJ_NOTNULL(hp, HTTP_MAGIC);
va_start(ap, p);
if (p == vrt_magic_string_unset) {
diff --git a/include/vrt.h b/include/vrt.h
index 9331600..2e720a2 100644
--- a/include/vrt.h
+++ b/include/vrt.h
@@ -208,6 +208,7 @@ int VRT_rewrite(const char *, const char *);
void VRT_error(VRT_CTX, unsigned, const char *);
int VRT_switch_config(const char *);
+struct http *VRT_selecthttp(VRT_CTX, enum gethdr_e);
const char *VRT_GetHdr(VRT_CTX, const struct gethdr_s *);
void VRT_SetHdr(VRT_CTX, const struct gethdr_s *, const char *, ...);
void VRT_handling(VRT_CTX, unsigned hand);
diff --git a/lib/libvmod_std/vmod_std.c b/lib/libvmod_std/vmod_std.c
index 35c417b..42b356a 100644
--- a/lib/libvmod_std/vmod_std.c
+++ b/lib/libvmod_std/vmod_std.c
@@ -174,16 +174,11 @@ vmod_syslog(VRT_CTX, VCL_INT fac, const char *fmt, ...)
VCL_VOID __match_proto__(td_std_collect)
vmod_collect(VRT_CTX, VCL_HEADER hdr)
{
+ struct http *hp;
CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
- if (hdr->where == HDR_REQ)
- http_CollectHdr(ctx->http_req, hdr->what);
- else if (hdr->where == HDR_BEREQ)
- http_CollectHdr(ctx->http_bereq, hdr->what);
- else if (hdr->where == HDR_BERESP)
- http_CollectHdr(ctx->http_beresp, hdr->what);
- else if (hdr->where == HDR_RESP)
- http_CollectHdr(ctx->http_resp, hdr->what);
+ hp = VRT_selecthttp(ctx, hdr->where);
+ http_CollectHdr(hp, hdr->what);
}
VCL_BOOL __match_proto__(td_std_healthy)
--
2.1.3
_______________________________________________
varnish-dev mailing list
[email protected]
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-dev