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
93686f85
Commit
93686f85
authored
Aug 10, 2011
by
Poul-Henning Kamp
Committed by
Tollef Fog Heen
Aug 17, 2011
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move the function which checks if we can do condiitional (304) delivery
into the RFC policy module where it belongs.
parent
af52295e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
38 additions
and
39 deletions
+38
-39
cache.h
bin/varnishd/cache.h
+1
-0
cache_response.c
bin/varnishd/cache_response.c
+4
-39
rfc2616.c
bin/varnishd/rfc2616.c
+33
-0
No files found.
bin/varnishd/cache.h
View file @
93686f85
...
...
@@ -937,6 +937,7 @@ unsigned WS_Free(const struct ws *ws);
double
RFC2616_Ttl
(
const
struct
sess
*
sp
);
enum
body_status
RFC2616_Body
(
const
struct
sess
*
sp
);
unsigned
RFC2616_Req_Gzip
(
const
struct
sess
*
sp
);
int
RFC2616_Do_Cond
(
const
struct
sess
*
sp
);
/* storage_synth.c */
struct
vsb
*
SMS_Makesynth
(
struct
object
*
obj
);
...
...
bin/varnishd/cache_response.c
View file @
93686f85
...
...
@@ -86,45 +86,8 @@ res_do_304(struct sess *sp)
/*--------------------------------------------------------------------*/
static
int
res_do_conds
(
struct
sess
*
sp
)
{
char
*
p
,
*
e
;
double
ims
;
int
do_cond
=
0
;
/* RFC 2616 13.3.4 states we need to match both ETag
and If-Modified-Since if present*/
if
(
http_GetHdr
(
sp
->
http
,
H_If_Modified_Since
,
&
p
)
)
{
if
(
!
sp
->
obj
->
last_modified
)
return
(
0
);
ims
=
TIM_parse
(
p
);
if
(
ims
>
sp
->
t_req
)
/* [RFC2616 14.25] */
return
(
0
);
if
(
sp
->
obj
->
last_modified
>
ims
)
return
(
0
);
do_cond
=
1
;
}
if
(
http_GetHdr
(
sp
->
http
,
H_If_None_Match
,
&
p
)
&&
http_GetHdr
(
sp
->
obj
->
http
,
H_ETag
,
&
e
))
{
if
(
strcmp
(
p
,
e
)
!=
0
)
return
(
0
);
do_cond
=
1
;
}
if
(
do_cond
==
1
)
{
res_do_304
(
sp
);
return
(
1
);
}
return
(
0
);
}
/*--------------------------------------------------------------------*/
static
void
res_dorange
(
struct
sess
*
sp
,
const
char
*
r
,
ssize_t
*
plow
,
ssize_t
*
phigh
)
res_dorange
(
const
struct
sess
*
sp
,
const
char
*
r
,
ssize_t
*
plow
,
ssize_t
*
phigh
)
{
ssize_t
low
,
high
,
has_low
;
...
...
@@ -196,8 +159,10 @@ RES_BuildHttp(struct sess *sp)
CHECK_OBJ_NOTNULL
(
sp
,
SESS_MAGIC
);
if
(
sp
->
obj
->
response
==
200
&&
sp
->
http
->
conds
&&
res_do_conds
(
sp
))
if
(
sp
->
obj
->
response
==
200
&&
sp
->
http
->
conds
&&
RFC2616_Do_Cond
(
sp
))
{
res_do_304
(
sp
);
return
;
}
http_ClrHeader
(
sp
->
wrk
->
resp
);
sp
->
wrk
->
resp
->
logtag
=
HTTP_Tx
;
...
...
bin/varnishd/rfc2616.c
View file @
93686f85
...
...
@@ -306,3 +306,36 @@ RFC2616_Req_Gzip(const struct sess *sp)
/* Bad client, no gzip. */
return
(
0
);
}
/*--------------------------------------------------------------------*/
int
RFC2616_Do_Cond
(
const
struct
sess
*
sp
)
{
char
*
p
,
*
e
;
double
ims
;
int
do_cond
=
0
;
/* RFC 2616 13.3.4 states we need to match both ETag
and If-Modified-Since if present*/
if
(
http_GetHdr
(
sp
->
http
,
H_If_Modified_Since
,
&
p
)
)
{
if
(
!
sp
->
obj
->
last_modified
)
return
(
0
);
ims
=
TIM_parse
(
p
);
if
(
ims
>
sp
->
t_req
)
/* [RFC2616 14.25] */
return
(
0
);
if
(
sp
->
obj
->
last_modified
>
ims
)
return
(
0
);
do_cond
=
1
;
}
if
(
http_GetHdr
(
sp
->
http
,
H_If_None_Match
,
&
p
)
&&
http_GetHdr
(
sp
->
obj
->
http
,
H_ETag
,
&
e
))
{
if
(
strcmp
(
p
,
e
)
!=
0
)
return
(
0
);
do_cond
=
1
;
}
return
(
do_cond
);
}
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