Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
varnish-cache
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
varnishcache
varnish-cache
Commits
9ee99237
Commit
9ee99237
authored
Apr 18, 2011
by
Poul-Henning Kamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix a problem in http_CollectHdr() where it would overlook
the second of two headers in a row. Fixes #902
parent
d75d6d2b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
60 additions
and
33 deletions
+60
-33
cache_http.c
bin/varnishd/cache_http.c
+33
-33
r00902.vtc
bin/varnishtest/tests/r00902.vtc
+27
-0
No files found.
bin/varnishd/cache_http.c
View file @
9ee99237
...
...
@@ -189,44 +189,44 @@ http_CollectHdr(struct http *hp, const char *hdr)
char
*
b
=
NULL
,
*
e
=
NULL
;
for
(
u
=
HTTP_HDR_FIRST
;
u
<
hp
->
nhd
;
u
++
)
{
Tcheck
(
hp
->
hd
[
u
]);
if
(
!
http_IsHdr
(
&
hp
->
hd
[
u
],
hdr
))
continue
;
if
(
f
==
0
)
{
/* Found first header, just record the fact */
f
=
u
;
continue
;
}
if
(
b
==
NULL
)
{
/* Found second header */
ml
=
WS_Reserve
(
hp
->
ws
,
0
);
b
=
hp
->
ws
->
f
;
e
=
b
+
ml
;
x
=
Tlen
(
hp
->
hd
[
f
]);
while
(
u
<
hp
->
nhd
&&
http_IsHdr
(
&
hp
->
hd
[
u
],
hdr
))
{
Tcheck
(
hp
->
hd
[
u
]);
if
(
f
==
0
)
{
/* Found first header, just record the fact */
f
=
u
;
break
;
}
if
(
b
==
NULL
)
{
/* Found second header, start our collection */
ml
=
WS_Reserve
(
hp
->
ws
,
0
);
b
=
hp
->
ws
->
f
;
e
=
b
+
ml
;
x
=
Tlen
(
hp
->
hd
[
f
]);
if
(
b
+
x
<
e
)
{
memcpy
(
b
,
hp
->
hd
[
f
].
b
,
x
);
b
+=
x
;
}
else
b
=
e
;
}
AN
(
b
);
AN
(
e
);
/* Append the Nth header we found */
if
(
b
<
e
)
*
b
++
=
','
;
x
=
Tlen
(
hp
->
hd
[
u
])
-
*
hdr
;
if
(
b
+
x
<
e
)
{
memcpy
(
b
,
hp
->
hd
[
f
].
b
,
x
);
memcpy
(
b
,
hp
->
hd
[
u
].
b
+
*
hdr
,
x
);
b
+=
x
;
}
else
b
=
e
;
}
AN
(
b
);
AN
(
e
);
/* Append the Nth header we found */
if
(
b
<
e
)
*
b
++
=
','
;
x
=
Tlen
(
hp
->
hd
[
u
])
-
*
hdr
;
if
(
b
+
x
<
e
)
{
memcpy
(
b
,
hp
->
hd
[
u
].
b
+
*
hdr
,
x
);
b
+=
x
;
}
else
b
=
e
;
/* Shift remaining headers up one slot */
for
(
v
=
u
;
v
<
hp
->
nhd
+
1
;
v
++
)
hp
->
hd
[
v
]
=
hp
->
hd
[
v
+
1
];
hp
->
nhd
--
;
/* Shift remaining headers up one slot */
for
(
v
=
u
;
v
<
hp
->
nhd
-
1
;
v
++
)
hp
->
hd
[
v
]
=
hp
->
hd
[
v
+
1
];
hp
->
nhd
--
;
}
}
if
(
b
==
NULL
)
...
...
bin/varnishtest/tests/r00902.vtc
0 → 100644
View file @
9ee99237
# $Id$
test "Ticket #902 http_CollectHdr() failure on consequitive headers"
server s1 {
rxreq
txresp \
-hdr "Server: Microsoft-IIS/5.0" \
-hdr "Cache-Control: A" \
-hdr "Cache-Control: B" \
-hdr "Cache-Control: C" \
-hdr "Cache-Control: D" \
-hdr "Foo: bar" \
-bodylen 5
} -start
varnish v1 -vcl+backend {
} -start
varnish v1 -cliok "param.set diag_bitmap 1"
client c1 {
txreq -hdr "foo: /foo"
rxresp
expect resp.http.cache-control == "A, B, C, D"
expect resp.http.foo == "bar"
} -run
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment