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
64693455
Commit
64693455
authored
Dec 11, 2015
by
Federico G. Schwindt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use a weak comparison function for If-None-Match
As per RFC 7232. Fixes #1816.
parent
e4637bb6
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
58 additions
and
11 deletions
+58
-11
cache_rfc2616.c
bin/varnishd/cache/cache_rfc2616.c
+22
-11
c00025.vtc
bin/varnishtest/tests/c00025.vtc
+36
-0
No files found.
bin/varnishd/cache/cache_rfc2616.c
View file @
64693455
...
...
@@ -232,6 +232,16 @@ RFC2616_Req_Gzip(const struct http *hp)
/*--------------------------------------------------------------------*/
static
inline
int
rfc2616_weak_compare
(
const
char
*
p
,
const
char
*
e
)
{
if
(
p
[
0
]
==
'W'
&&
p
[
1
]
==
'/'
)
p
+=
2
;
if
(
e
[
0
]
==
'W'
&&
e
[
1
]
==
'/'
)
e
+=
2
;
return
(
strcmp
(
p
,
e
)
!=
0
);
}
int
RFC2616_Do_Cond
(
const
struct
req
*
req
)
{
...
...
@@ -239,12 +249,20 @@ RFC2616_Do_Cond(const struct req *req)
double
ims
,
lm
;
int
do_cond
=
0
;
/* RFC 2616 13.3.4 states we need to match both ETag
and If-Modified-Since if present*/
/*
* RFC 2616 13.3.4 states we need to match both ETag and
* If-Modified-Since if present.
*/
if
(
http_GetHdr
(
req
->
http
,
H_If_None_Match
,
&
p
)
&&
http_GetHdr
(
req
->
resp
,
H_ETag
,
&
e
))
{
if
(
rfc2616_weak_compare
(
p
,
e
))
return
(
0
);
do_cond
=
1
;
}
if
(
http_GetHdr
(
req
->
http
,
H_If_Modified_Since
,
&
p
)
)
{
if
(
http_GetHdr
(
req
->
http
,
H_If_Modified_Since
,
&
p
))
{
ims
=
VTIM_parse
(
p
);
if
(
ims
>
req
->
t_req
)
/* [RFC2616 14.25] */
if
(
!
ims
||
ims
>
req
->
t_req
)
/* [RFC2616 14.25] */
return
(
0
);
AZ
(
ObjGetDouble
(
req
->
wrk
,
req
->
objcore
,
OA_LASTMODIFIED
,
&
lm
));
if
(
lm
>
ims
)
...
...
@@ -252,13 +270,6 @@ RFC2616_Do_Cond(const struct req *req)
do_cond
=
1
;
}
if
(
http_GetHdr
(
req
->
http
,
H_If_None_Match
,
&
p
)
&&
http_GetHdr
(
req
->
resp
,
H_ETag
,
&
e
))
{
if
(
strcmp
(
p
,
e
)
!=
0
)
return
(
0
);
do_cond
=
1
;
}
return
(
do_cond
);
}
...
...
bin/varnishtest/tests/c00025.vtc
View file @
64693455
...
...
@@ -4,6 +4,10 @@ server s1 {
rxreq
expect req.url == /
txresp -hdr {ETag: "123456789"} -bodylen 10
rxreq
expect req.url == /other
txresp -hdr {ETag: W/"123456789"} -bodylen 10
} -start
varnish v1 -vcl+backend { } -start
...
...
@@ -22,4 +26,36 @@ client c1 {
txreq -hdr {If-None-Match: "123456789"}
rxresp -no_obj
expect resp.status == 304
txreq -hdr {If-None-Match: W/"12345678"}
rxresp
expect resp.status == 200
txreq -hdr {If-None-Match: W/"123456789"}
rxresp -no_obj
expect resp.status == 304
} -run
client c2 {
txreq -url /other
rxresp
expect resp.status == 200
expect resp.bodylen == 10
expect resp.http.etag == {W/"123456789"}
txreq -url /other -hdr {If-None-Match: "12345678"}
rxresp
expect resp.status == 200
txreq -url /other -hdr {If-None-Match: "123456789"}
rxresp -no_obj
expect resp.status == 304
txreq -url /other -hdr {If-None-Match: W/"12345678"}
rxresp
expect resp.status == 200
txreq -url /other -hdr {If-None-Match: W/"123456789"}
rxresp -no_obj
expect resp.status == 304
} -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