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
5fbe576f
Commit
5fbe576f
authored
Sep 20, 2017
by
Poul-Henning Kamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move the beresp body determination to rfc2616 territory.
parent
8efe9c1f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
75 additions
and
62 deletions
+75
-62
cache.h
bin/varnishd/cache/cache.h
+1
-0
cache_fetch.c
bin/varnishd/cache/cache_fetch.c
+9
-62
cache_rfc2616.c
bin/varnishd/cache/cache_rfc2616.c
+65
-0
No files found.
bin/varnishd/cache/cache.h
View file @
5fbe576f
...
@@ -1076,6 +1076,7 @@ unsigned RFC2616_Req_Gzip(const struct http *);
...
@@ -1076,6 +1076,7 @@ unsigned RFC2616_Req_Gzip(const struct http *);
int
RFC2616_Do_Cond
(
const
struct
req
*
sp
);
int
RFC2616_Do_Cond
(
const
struct
req
*
sp
);
void
RFC2616_Weaken_Etag
(
struct
http
*
hp
);
void
RFC2616_Weaken_Etag
(
struct
http
*
hp
);
void
RFC2616_Vary_AE
(
struct
http
*
hp
);
void
RFC2616_Vary_AE
(
struct
http
*
hp
);
void
RFC2616_Response_Body
(
const
struct
worker
*
,
const
struct
busyobj
*
);
/* stevedore.c */
/* stevedore.c */
int
STV_NewObject
(
struct
worker
*
,
struct
objcore
*
,
int
STV_NewObject
(
struct
worker
*
,
struct
objcore
*
,
...
...
bin/varnishd/cache/cache_fetch.c
View file @
5fbe576f
...
@@ -304,6 +304,15 @@ vbf_stp_startfetch(struct worker *wrk, struct busyobj *bo)
...
@@ -304,6 +304,15 @@ vbf_stp_startfetch(struct worker *wrk, struct busyobj *bo)
http_VSL_log
(
bo
->
beresp
);
http_VSL_log
(
bo
->
beresp
);
RFC2616_Response_Body
(
wrk
,
bo
);
if
(
bo
->
htc
->
body_status
==
BS_ERROR
)
{
bo
->
htc
->
doclose
=
SC_RX_BODY
;
VDI_Finish
(
bo
->
wrk
,
bo
);
VSLb
(
bo
->
vsl
,
SLT_Error
,
"Body cannot be fetched"
);
assert
(
bo
->
director_state
==
DIR_S_NULL
);
return
(
F_STP_ERROR
);
}
if
(
!
http_GetHdr
(
bo
->
beresp
,
H_Date
,
NULL
))
{
if
(
!
http_GetHdr
(
bo
->
beresp
,
H_Date
,
NULL
))
{
/*
/*
* RFC 2616 14.18 Date: The Date general-header field
* RFC 2616 14.18 Date: The Date general-header field
...
@@ -327,68 +336,6 @@ vbf_stp_startfetch(struct worker *wrk, struct busyobj *bo)
...
@@ -327,68 +336,6 @@ vbf_stp_startfetch(struct worker *wrk, struct busyobj *bo)
http_CollectHdr
(
bo
->
beresp
,
H_Cache_Control
);
http_CollectHdr
(
bo
->
beresp
,
H_Cache_Control
);
http_CollectHdr
(
bo
->
beresp
,
H_Vary
);
http_CollectHdr
(
bo
->
beresp
,
H_Vary
);
/*
* Figure out how the fetch is supposed to happen, before the
* headers are adultered by VCL
*/
if
(
!
strcasecmp
(
http_GetMethod
(
bo
->
bereq
),
"head"
))
{
/*
* A HEAD request can never have a body in the reply,
* no matter what the headers might say.
* [RFC7231 4.3.2 p25]
*/
wrk
->
stats
->
fetch_head
++
;
bo
->
htc
->
body_status
=
BS_NONE
;
}
else
if
(
http_GetStatus
(
bo
->
beresp
)
<=
199
)
{
/*
* 1xx responses never have a body.
* [RFC7230 3.3.2 p31]
* ... but we should never see them.
*/
wrk
->
stats
->
fetch_1xx
++
;
bo
->
htc
->
body_status
=
BS_ERROR
;
}
else
if
(
http_IsStatus
(
bo
->
beresp
,
204
))
{
/*
* 204 is "No Content", obviously don't expect a body.
* [RFC7230 3.3.1 p29 and 3.3.2 p31]
*/
wrk
->
stats
->
fetch_204
++
;
if
((
http_GetHdr
(
bo
->
beresp
,
H_Content_Length
,
NULL
)
&&
bo
->
htc
->
content_length
!=
0
)
||
http_GetHdr
(
bo
->
beresp
,
H_Transfer_Encoding
,
NULL
))
bo
->
htc
->
body_status
=
BS_ERROR
;
else
bo
->
htc
->
body_status
=
BS_NONE
;
}
else
if
(
http_IsStatus
(
bo
->
beresp
,
304
))
{
/*
* 304 is "Not Modified" it has no body.
* [RFC7230 3.3 p28]
*/
wrk
->
stats
->
fetch_304
++
;
bo
->
htc
->
body_status
=
BS_NONE
;
}
else
if
(
bo
->
htc
->
body_status
==
BS_CHUNKED
)
{
wrk
->
stats
->
fetch_chunked
++
;
}
else
if
(
bo
->
htc
->
body_status
==
BS_LENGTH
)
{
assert
(
bo
->
htc
->
content_length
>
0
);
wrk
->
stats
->
fetch_length
++
;
}
else
if
(
bo
->
htc
->
body_status
==
BS_EOF
)
{
wrk
->
stats
->
fetch_eof
++
;
}
else
if
(
bo
->
htc
->
body_status
==
BS_ERROR
)
{
wrk
->
stats
->
fetch_bad
++
;
}
else
if
(
bo
->
htc
->
body_status
==
BS_NONE
)
{
wrk
->
stats
->
fetch_none
++
;
}
else
{
WRONG
(
"wrong bodystatus"
);
}
if
(
bo
->
htc
->
body_status
==
BS_ERROR
)
{
bo
->
htc
->
doclose
=
SC_RX_BODY
;
VDI_Finish
(
bo
->
wrk
,
bo
);
VSLb
(
bo
->
vsl
,
SLT_Error
,
"Body cannot be fetched"
);
assert
(
bo
->
director_state
==
DIR_S_NULL
);
return
(
F_STP_ERROR
);
}
if
(
bo
->
fetch_objcore
->
flags
&
OC_F_PRIVATE
)
{
if
(
bo
->
fetch_objcore
->
flags
&
OC_F_PRIVATE
)
{
/* private objects have negative TTL */
/* private objects have negative TTL */
bo
->
fetch_objcore
->
t_origin
=
now
;
bo
->
fetch_objcore
->
t_origin
=
now
;
...
...
bin/varnishd/cache/cache_rfc2616.c
View file @
5fbe576f
...
@@ -325,3 +325,68 @@ RFC2616_Vary_AE(struct http *hp)
...
@@ -325,3 +325,68 @@ RFC2616_Vary_AE(struct http *hp)
http_SetHeader
(
hp
,
"Vary: Accept-Encoding"
);
http_SetHeader
(
hp
,
"Vary: Accept-Encoding"
);
}
}
}
}
/*--------------------------------------------------------------------*/
void
RFC2616_Response_Body
(
const
struct
worker
*
wrk
,
const
struct
busyobj
*
bo
)
{
CHECK_OBJ_NOTNULL
(
wrk
,
WORKER_MAGIC
);
CHECK_OBJ_NOTNULL
(
bo
,
BUSYOBJ_MAGIC
);
/*
* Figure out how the fetch is supposed to happen, before the
* headers are adultered by VCL
*/
if
(
!
strcasecmp
(
http_GetMethod
(
bo
->
bereq
),
"head"
))
{
/*
* A HEAD request can never have a body in the reply,
* no matter what the headers might say.
* [RFC7231 4.3.2 p25]
*/
wrk
->
stats
->
fetch_head
++
;
bo
->
htc
->
body_status
=
BS_NONE
;
}
else
if
(
http_GetStatus
(
bo
->
beresp
)
<=
199
)
{
/*
* 1xx responses never have a body.
* [RFC7230 3.3.2 p31]
* ... but we should never see them.
*/
wrk
->
stats
->
fetch_1xx
++
;
bo
->
htc
->
body_status
=
BS_ERROR
;
}
else
if
(
http_IsStatus
(
bo
->
beresp
,
204
))
{
/*
* 204 is "No Content", obviously don't expect a body.
* [RFC7230 3.3.1 p29 and 3.3.2 p31]
*/
wrk
->
stats
->
fetch_204
++
;
if
((
http_GetHdr
(
bo
->
beresp
,
H_Content_Length
,
NULL
)
&&
bo
->
htc
->
content_length
!=
0
)
||
http_GetHdr
(
bo
->
beresp
,
H_Transfer_Encoding
,
NULL
))
bo
->
htc
->
body_status
=
BS_ERROR
;
else
bo
->
htc
->
body_status
=
BS_NONE
;
}
else
if
(
http_IsStatus
(
bo
->
beresp
,
304
))
{
/*
* 304 is "Not Modified" it has no body.
* [RFC7230 3.3 p28]
*/
wrk
->
stats
->
fetch_304
++
;
bo
->
htc
->
body_status
=
BS_NONE
;
}
else
if
(
bo
->
htc
->
body_status
==
BS_CHUNKED
)
{
wrk
->
stats
->
fetch_chunked
++
;
}
else
if
(
bo
->
htc
->
body_status
==
BS_LENGTH
)
{
assert
(
bo
->
htc
->
content_length
>
0
);
wrk
->
stats
->
fetch_length
++
;
}
else
if
(
bo
->
htc
->
body_status
==
BS_EOF
)
{
wrk
->
stats
->
fetch_eof
++
;
}
else
if
(
bo
->
htc
->
body_status
==
BS_ERROR
)
{
wrk
->
stats
->
fetch_bad
++
;
}
else
if
(
bo
->
htc
->
body_status
==
BS_NONE
)
{
wrk
->
stats
->
fetch_none
++
;
}
else
{
WRONG
(
"wrong bodystatus"
);
}
}
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