Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
Zope
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
Zope
Commits
7508b239
Commit
7508b239
authored
Apr 25, 2009
by
Laurence Rowe
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
don't append Accept-Encoding to Vary header unnecessarily
parent
d7bf2837
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
1 deletion
+17
-1
src/ZPublisher/HTTPResponse.py
src/ZPublisher/HTTPResponse.py
+3
-1
src/ZPublisher/tests/testHTTPResponse.py
src/ZPublisher/tests/testHTTPResponse.py
+14
-0
No files found.
src/ZPublisher/HTTPResponse.py
View file @
7508b239
...
...
@@ -398,6 +398,8 @@ class HTTPResponse(BaseResponse):
# was ignored anyway, so cache should not
# vary on it. Otherwise if not forced, cache should
# respect Accept-Encoding client header
vary
=
self
.
getHeader
(
'Vary'
)
if
vary
is
None
or
'Accept-Encoding'
not
in
vary
:
self
.
appendHeader
(
'Vary'
,
'Accept-Encoding'
)
return
self
...
...
src/ZPublisher/tests/testHTTPResponse.py
View file @
7508b239
...
...
@@ -180,6 +180,20 @@ class HTTPResponseTests(unittest.TestCase):
'Set-Cookie: '
'violation="http://www.ietf.org/rfc/rfc2616.txt"
\
r
\
n
'
)
def
test_setBody_compression_vary
(
self
):
# Vary header should be added here
response
=
self
.
_makeOne
()
response
.
enableHTTPCompression
(
REQUEST
=
{
'HTTP_ACCEPT_ENCODING'
:
'gzip'
})
response
.
setBody
(
'foo'
*
100
)
# body must get smaller on compression
self
.
assertEqual
(
'Accept-Encoding'
in
response
.
getHeader
(
'Vary'
),
True
)
# But here it would be unnecessary
response
=
self
.
_makeOne
()
response
.
enableHTTPCompression
(
REQUEST
=
{
'HTTP_ACCEPT_ENCODING'
:
'gzip'
})
response
.
setHeader
(
'Vary'
,
'Accept-Encoding,Accept-Language'
)
before
=
response
.
getHeader
(
'Vary'
)
response
.
setBody
(
'foo'
*
100
)
self
.
assertEqual
(
before
,
response
.
getHeader
(
'Vary'
))
def
test_suite
():
suite
=
unittest
.
TestSuite
()
...
...
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