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
df07a42e
Commit
df07a42e
authored
Jun 20, 2002
by
Brian Lloyd
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Merged Brad Clements compression refinements.
parent
acac2b72
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
8 deletions
+22
-8
lib/python/ZPublisher/HTTPResponse.py
lib/python/ZPublisher/HTTPResponse.py
+22
-8
No files found.
lib/python/ZPublisher/HTTPResponse.py
View file @
df07a42e
...
...
@@ -12,8 +12,8 @@
##############################################################################
'''CGI Response Output formatter
$Id: HTTPResponse.py,v 1.6
3 2002/06/14 15:52:49
Brian Exp $'''
__version__
=
'$Revision: 1.6
3
$'
[
11
:
-
2
]
$Id: HTTPResponse.py,v 1.6
4 2002/06/20 15:17:07
Brian Exp $'''
__version__
=
'$Revision: 1.6
4
$'
[
11
:
-
2
]
import
types
,
os
,
sys
,
re
import
zlib
,
struct
...
...
@@ -145,7 +145,12 @@ class HTTPResponse(BaseResponse):
realm
=
'Zope'
_error_format
=
'text/html'
_locked_status
=
0
use_HTTP_content_compression
=
0
# indicate if setBody should content-compress output
# Indicate if setBody should content-compress output.
# 0 - no compression
# 1 - compress if accept-encoding ok
# 2 - ignore accept-encoding (i.e. force)
use_HTTP_content_compression
=
0
def
__init__
(
self
,
body
=
''
,
status
=
200
,
headers
=
None
,
stdout
=
sys
.
stdout
,
stderr
=
sys
.
stderr
,):
...
...
@@ -331,7 +336,14 @@ class HTTPResponse(BaseResponse):
self
.
body
=
z
self
.
setHeader
(
'content-length'
,
newlen
)
self
.
setHeader
(
'content-encoding'
,
'gzip'
)
if
self
.
use_HTTP_content_compression
==
1
:
# use_HTTP_content_compression == 1 if force was
# NOT used in enableHTTPCompression().
# If we forced it, then Accept-Encoding
# was ignored anyway, so cache should not
# vary on it. Otherwise if not forced, cache should
# respect Accept-Encoding client header
self
.
appendHeader
(
'Vary'
,
'Accept-Encoding'
)
return
self
def
enableHTTPCompression
(
self
,
REQUEST
=
{},
force
=
0
,
disable
=
0
,
query
=
0
):
...
...
@@ -342,7 +354,8 @@ class HTTPResponse(BaseResponse):
disable -- set true to disable compression
query -- just return if compression has been previously requested
returns -- 1 if compression will be performed, 0 otherwise
returns -- 1 if compression will be attempted, 2 if compression
is forced, 0 if no compression
The HTTP specification allows for transfer encoding and content
encoding. Unfortunately many web browsers still do not support
...
...
@@ -377,9 +390,10 @@ class HTTPResponse(BaseResponse):
self
.
use_HTTP_content_compression
=
0
elif
force
or
(
REQUEST
.
get
(
'HTTP_ACCEPT_ENCODING'
,
''
).
find
(
'gzip'
)
!=
-
1
):
self
.
use_HTTP_content_compression
=
1
if
not
force
:
self
.
appendHeader
(
'Vary'
,
'Accept-Encoding'
)
if
force
:
self
.
use_HTTP_content_compression
=
2
else
:
self
.
use_HTTP_content_compression
=
1
return
self
.
use_HTTP_content_compression
...
...
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