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
4d5a73ba
Commit
4d5a73ba
authored
Aug 07, 2014
by
Poul-Henning Kamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Don't frob http->status directly to test value, we need to take
account for the extra two digits made available for VCL.
parent
a25a2b67
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
24 additions
and
13 deletions
+24
-13
cache.h
bin/varnishd/cache/cache.h
+1
-0
cache_fetch.c
bin/varnishd/cache/cache_fetch.c
+3
-3
cache_http.c
bin/varnishd/cache/cache_http.c
+9
-0
cache_http1_deliver.c
bin/varnishd/cache/cache_http1_deliver.c
+5
-5
cache_req_fsm.c
bin/varnishd/cache/cache_req_fsm.c
+1
-1
cache_rfc2616.c
bin/varnishd/cache/cache_rfc2616.c
+5
-4
No files found.
bin/varnishd/cache/cache.h
View file @
4d5a73ba
...
@@ -967,6 +967,7 @@ int http_GetHdrField(const struct http *hp, const char *hdr,
...
@@ -967,6 +967,7 @@ int http_GetHdrField(const struct http *hp, const char *hdr,
const
char
*
field
,
char
**
ptr
);
const
char
*
field
,
char
**
ptr
);
double
http_GetHdrQ
(
const
struct
http
*
hp
,
const
char
*
hdr
,
const
char
*
field
);
double
http_GetHdrQ
(
const
struct
http
*
hp
,
const
char
*
hdr
,
const
char
*
field
);
uint16_t
http_GetStatus
(
const
struct
http
*
hp
);
uint16_t
http_GetStatus
(
const
struct
http
*
hp
);
int
http_IsStatus
(
const
struct
http
*
hp
,
int
);
void
http_SetStatus
(
struct
http
*
to
,
uint16_t
status
);
void
http_SetStatus
(
struct
http
*
to
,
uint16_t
status
);
const
char
*
http_GetReq
(
const
struct
http
*
hp
);
const
char
*
http_GetReq
(
const
struct
http
*
hp
);
int
http_HdrIs
(
const
struct
http
*
hp
,
const
char
*
hdr
,
const
char
*
val
);
int
http_HdrIs
(
const
struct
http
*
hp
,
const
char
*
hdr
,
const
char
*
val
);
...
...
bin/varnishd/cache/cache_fetch.c
View file @
4d5a73ba
...
@@ -203,7 +203,7 @@ vbf_stp_mkbereq(const struct worker *wrk, struct busyobj *bo)
...
@@ -203,7 +203,7 @@ vbf_stp_mkbereq(const struct worker *wrk, struct busyobj *bo)
http_CopyHome
(
bo
->
bereq0
);
http_CopyHome
(
bo
->
bereq0
);
}
}
if
(
bo
->
ims_obj
!=
NULL
&&
bo
->
ims_obj
->
http
->
status
==
200
)
{
if
(
bo
->
ims_obj
!=
NULL
&&
http_IsStatus
(
bo
->
ims_obj
->
http
,
200
)
)
{
if
(
http_GetHdr
(
bo
->
ims_obj
->
http
,
H_Last_Modified
,
&
p
))
{
if
(
http_GetHdr
(
bo
->
ims_obj
->
http
,
H_Last_Modified
,
&
p
))
{
http_PrintfHeader
(
bo
->
bereq0
,
http_PrintfHeader
(
bo
->
bereq0
,
"If-Modified-Since: %s"
,
p
);
"If-Modified-Since: %s"
,
p
);
...
@@ -351,10 +351,10 @@ vbf_stp_startfetch(struct worker *wrk, struct busyobj *bo)
...
@@ -351,10 +351,10 @@ vbf_stp_startfetch(struct worker *wrk, struct busyobj *bo)
AZ
(
bo
->
do_esi
);
AZ
(
bo
->
do_esi
);
if
(
bo
->
ims_obj
!=
NULL
&&
bo
->
beresp
->
status
==
304
)
{
if
(
bo
->
ims_obj
!=
NULL
&&
http_IsStatus
(
bo
->
beresp
,
304
)
)
{
http_Merge
(
bo
->
ims_obj
->
http
,
bo
->
beresp
,
http_Merge
(
bo
->
ims_obj
->
http
,
bo
->
beresp
,
bo
->
ims_obj
->
changed_gzip
);
bo
->
ims_obj
->
changed_gzip
);
assert
(
bo
->
beresp
->
status
==
200
);
assert
(
http_IsStatus
(
bo
->
beresp
,
200
)
);
do_ims
=
1
;
do_ims
=
1
;
}
else
}
else
do_ims
=
0
;
do_ims
=
0
;
...
...
bin/varnishd/cache/cache_http.c
View file @
4d5a73ba
...
@@ -532,6 +532,15 @@ http_GetStatus(const struct http *hp)
...
@@ -532,6 +532,15 @@ http_GetStatus(const struct http *hp)
return
(
hp
->
status
);
return
(
hp
->
status
);
}
}
int
http_IsStatus
(
const
struct
http
*
hp
,
int
val
)
{
CHECK_OBJ_NOTNULL
(
hp
,
HTTP_MAGIC
);
assert
(
val
>=
100
&&
val
<=
999
);
return
(
val
==
(
hp
->
status
%
1000
));
}
/*--------------------------------------------------------------------
/*--------------------------------------------------------------------
* Setting the status will also set the Reason appropriately
* Setting the status will also set the Reason appropriately
*/
*/
...
...
bin/varnishd/cache/cache_http1_deliver.c
View file @
4d5a73ba
...
@@ -93,7 +93,7 @@ v1d_dorange(struct req *req, struct busyobj *bo, const char *r)
...
@@ -93,7 +93,7 @@ v1d_dorange(struct req *req, struct busyobj *bo, const char *r)
CHECK_OBJ_NOTNULL
(
req
,
REQ_MAGIC
);
CHECK_OBJ_NOTNULL
(
req
,
REQ_MAGIC
);
CHECK_OBJ_NOTNULL
(
req
->
obj
,
OBJECT_MAGIC
);
CHECK_OBJ_NOTNULL
(
req
->
obj
,
OBJECT_MAGIC
);
assert
(
http_
GetStatus
(
req
->
resp
)
==
200
);
assert
(
http_
IsStatus
(
req
->
resp
,
200
)
);
/* We must snapshot the length if we're streaming from the backend */
/* We must snapshot the length if we're streaming from the backend */
if
(
bo
!=
NULL
)
if
(
bo
!=
NULL
)
...
@@ -244,7 +244,7 @@ V1D_Deliver(struct req *req, struct busyobj *bo)
...
@@ -244,7 +244,7 @@ V1D_Deliver(struct req *req, struct busyobj *bo)
/* In ESI mode, we can't know the aggregate length */
/* In ESI mode, we can't know the aggregate length */
req
->
res_mode
&=
~
RES_LEN
;
req
->
res_mode
&=
~
RES_LEN
;
req
->
res_mode
|=
RES_ESI
;
req
->
res_mode
|=
RES_ESI
;
}
else
if
(
req
->
resp
->
status
==
304
)
{
}
else
if
(
http_IsStatus
(
req
->
resp
,
304
)
)
{
req
->
res_mode
&=
~
RES_LEN
;
req
->
res_mode
&=
~
RES_LEN
;
http_Unset
(
req
->
resp
,
H_Content_Length
);
http_Unset
(
req
->
resp
,
H_Content_Length
);
req
->
wantbody
=
0
;
req
->
wantbody
=
0
;
...
@@ -308,7 +308,7 @@ V1D_Deliver(struct req *req, struct busyobj *bo)
...
@@ -308,7 +308,7 @@ V1D_Deliver(struct req *req, struct busyobj *bo)
req
->
wantbody
&&
req
->
wantbody
&&
!
(
req
->
res_mode
&
(
RES_ESI
|
RES_ESI_CHILD
))
&&
!
(
req
->
res_mode
&
(
RES_ESI
|
RES_ESI_CHILD
))
&&
cache_param
->
http_range_support
&&
cache_param
->
http_range_support
&&
http_
GetStatus
(
req
->
resp
)
==
200
)
{
http_
IsStatus
(
req
->
resp
,
200
)
)
{
http_SetHeader
(
req
->
resp
,
"Accept-Ranges: bytes"
);
http_SetHeader
(
req
->
resp
,
"Accept-Ranges: bytes"
);
if
(
http_GetHdr
(
req
->
http
,
H_Range
,
&
r
))
if
(
http_GetHdr
(
req
->
http
,
H_Range
,
&
r
))
v1d_dorange
(
req
,
bo
,
r
);
v1d_dorange
(
req
,
bo
,
r
);
...
@@ -373,7 +373,7 @@ V1D_Deliver_Synth(struct req *req)
...
@@ -373,7 +373,7 @@ V1D_Deliver_Synth(struct req *req)
AN
(
req
->
synth_body
);
AN
(
req
->
synth_body
);
req
->
res_mode
=
0
;
req
->
res_mode
=
0
;
if
(
req
->
resp
->
status
==
304
)
{
if
(
http_IsStatus
(
req
->
resp
,
304
)
)
{
req
->
res_mode
&=
~
RES_LEN
;
req
->
res_mode
&=
~
RES_LEN
;
http_Unset
(
req
->
resp
,
H_Content_Length
);
http_Unset
(
req
->
resp
,
H_Content_Length
);
req
->
wantbody
=
0
;
req
->
wantbody
=
0
;
...
@@ -422,7 +422,7 @@ V1D_Deliver_Synth(struct req *req)
...
@@ -422,7 +422,7 @@ V1D_Deliver_Synth(struct req *req)
req
->
wantbody
&&
req
->
wantbody
&&
!
(
req
->
res_mode
&
RES_ESI_CHILD
)
&&
!
(
req
->
res_mode
&
RES_ESI_CHILD
)
&&
cache_param
->
http_range_support
&&
cache_param
->
http_range_support
&&
http_
GetStatus
(
req
->
resp
)
==
200
)
{
http_
IsStatus
(
req
->
resp
,
200
)
)
{
http_SetHeader
(
req
->
resp
,
"Accept-Ranges: bytes"
);
http_SetHeader
(
req
->
resp
,
"Accept-Ranges: bytes"
);
if
(
http_GetHdr
(
req
->
http
,
H_Range
,
&
r
))
if
(
http_GetHdr
(
req
->
http
,
H_Range
,
&
r
))
v1d_dorange
(
req
,
NULL
,
r
);
v1d_dorange
(
req
,
NULL
,
r
);
...
...
bin/varnishd/cache/cache_req_fsm.c
View file @
4d5a73ba
...
@@ -163,7 +163,7 @@ cnt_deliver(struct worker *wrk, struct req *req)
...
@@ -163,7 +163,7 @@ cnt_deliver(struct worker *wrk, struct req *req)
if
(
!
(
req
->
objcore
->
flags
&
OC_F_PASS
)
if
(
!
(
req
->
objcore
->
flags
&
OC_F_PASS
)
&&
req
->
esi_level
==
0
&&
req
->
esi_level
==
0
&&
http_
GetStatus
(
req
->
resp
)
==
200
&&
http_
IsStatus
(
req
->
resp
,
200
)
&&
req
->
http
->
conds
&&
RFC2616_Do_Cond
(
req
))
{
&&
req
->
http
->
conds
&&
RFC2616_Do_Cond
(
req
))
{
http_PutResponse
(
req
->
resp
,
"HTTP/1.1"
,
304
,
NULL
);
http_PutResponse
(
req
->
resp
,
"HTTP/1.1"
,
304
,
NULL
);
req
->
wantbody
=
0
;
req
->
wantbody
=
0
;
...
...
bin/varnishd/cache/cache_rfc2616.c
View file @
4d5a73ba
...
@@ -207,16 +207,17 @@ RFC2616_Body(struct busyobj *bo, struct dstat *stats)
...
@@ -207,16 +207,17 @@ RFC2616_Body(struct busyobj *bo, struct dstat *stats)
return
(
BS_NONE
);
return
(
BS_NONE
);
}
}
if
(
h
p
->
status
<=
199
)
{
if
(
h
ttp_GetStatus
(
hp
)
<=
199
)
{
/*
/*
* 1xx responses never have a body.
* 1xx responses never have a body.
* [RFC2616 4.3 p33]
* [RFC2616 4.3 p33]
* ... but we should never see them.
*/
*/
stats
->
fetch_1xx
++
;
stats
->
fetch_1xx
++
;
return
(
BS_
NONE
);
return
(
BS_
ERROR
);
}
}
if
(
h
p
->
status
==
204
)
{
if
(
h
ttp_IsStatus
(
hp
,
204
)
)
{
/*
/*
* 204 is "No Content", obviously don't expect a body.
* 204 is "No Content", obviously don't expect a body.
* [RFC2616 10.2.5 p60]
* [RFC2616 10.2.5 p60]
...
@@ -225,7 +226,7 @@ RFC2616_Body(struct busyobj *bo, struct dstat *stats)
...
@@ -225,7 +226,7 @@ RFC2616_Body(struct busyobj *bo, struct dstat *stats)
return
(
BS_NONE
);
return
(
BS_NONE
);
}
}
if
(
h
p
->
status
==
304
)
{
if
(
h
ttp_IsStatus
(
hp
,
304
)
)
{
/*
/*
* 304 is "Not Modified" it has no body.
* 304 is "Not Modified" it has no body.
* [RFC2616 10.3.5 p63]
* [RFC2616 10.3.5 p63]
...
...
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