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

Properly emit the header name in VRT_SetHdr();



git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@1664 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent e0fbd8b7
...@@ -113,7 +113,7 @@ VRT_GetHdr(struct sess *sp, enum gethdr_e where, const char *n) ...@@ -113,7 +113,7 @@ VRT_GetHdr(struct sess *sp, enum gethdr_e where, const char *n)
/*--------------------------------------------------------------------*/ /*--------------------------------------------------------------------*/
static char * static char *
vrt_assemble_string(struct http *hp, const char *p, va_list ap) vrt_assemble_string(struct http *hp, const char *h, const char *p, va_list ap)
{ {
char *b, *e; char *b, *e;
unsigned u, x; unsigned u, x;
...@@ -121,6 +121,15 @@ vrt_assemble_string(struct http *hp, const char *p, va_list ap) ...@@ -121,6 +121,15 @@ vrt_assemble_string(struct http *hp, const char *p, va_list ap)
u = WS_Reserve(hp->ws, 0); u = WS_Reserve(hp->ws, 0);
e = b = hp->ws->f; e = b = hp->ws->f;
*e = '\0'; *e = '\0';
if (h != NULL) {
x = strlen(h);
if (x + 2 < u) {
memcpy(e, h, x);
e[x] = ' ';
e[x + 1] = '\0';
}
e += x + 1;
}
while (p != NULL) { while (p != NULL) {
x = strlen(p); x = strlen(p);
if (x + 1 < u) if (x + 1 < u)
...@@ -141,21 +150,19 @@ vrt_assemble_string(struct http *hp, const char *p, va_list ap) ...@@ -141,21 +150,19 @@ vrt_assemble_string(struct http *hp, const char *p, va_list ap)
/*--------------------------------------------------------------------*/ /*--------------------------------------------------------------------*/
void void
VRT_SetHdr(struct sess *sp , enum gethdr_e where, const char *hdr, ...) VRT_SetHdr(struct sess *sp , enum gethdr_e where, const char *hdr, const char *p, ...)
{ {
struct http *hp; struct http *hp;
va_list ap; va_list ap;
const char *p;
char *b; char *b;
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
hp = vrt_selecthttp(sp, where); hp = vrt_selecthttp(sp, where);
va_start(ap, hdr); va_start(ap, p);
p = va_arg(ap, const char *);
if (p == NULL) { if (p == NULL) {
http_Unset(hp, hdr); http_Unset(hp, hdr);
} else { } else {
b = vrt_assemble_string(hp, p, ap); b = vrt_assemble_string(hp, hdr + 1, p, ap);
if (b == NULL) { if (b == NULL) {
VSL(SLT_LostHeader, sp->fd, hdr + 1); VSL(SLT_LostHeader, sp->fd, hdr + 1);
} else { } else {
...@@ -175,7 +182,7 @@ vrt_do_string(struct worker *w, int fd, struct http *hp, int fld, const char *er ...@@ -175,7 +182,7 @@ vrt_do_string(struct worker *w, int fd, struct http *hp, int fld, const char *er
AN(p); AN(p);
AN(hp); AN(hp);
b = vrt_assemble_string(hp, p, ap); b = vrt_assemble_string(hp, NULL, p, ap);
if (b == NULL) { if (b == NULL) {
WSL(w, SLT_LostHeader, fd, err); WSL(w, SLT_LostHeader, fd, err);
} else { } else {
......
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