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
1d77cd6c
Commit
1d77cd6c
authored
Oct 08, 2006
by
Andreas Jung
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- Collector #2208: rewriting/setting the 'charset' part of the content-type
HTTP header will be done only for 'text/*'
parent
6ec027e2
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
3 deletions
+13
-3
doc/CHANGES.txt
doc/CHANGES.txt
+3
-0
lib/python/ZPublisher/HTTPResponse.py
lib/python/ZPublisher/HTTPResponse.py
+1
-1
lib/python/ZPublisher/tests/testHTTPResponse.py
lib/python/ZPublisher/tests/testHTTPResponse.py
+9
-2
No files found.
doc/CHANGES.txt
View file @
1d77cd6c
...
...
@@ -11,6 +11,9 @@ Zope Changes
- Collector #2205: fixed wrong logger argument in ZRDB/Connection.py
- Collector #2208: rewriting/setting the 'charset' part of the content-type
HTTP header will be done only for 'text/*'
Zope 2.9.5 (2006/10/03)
...
...
lib/python/ZPublisher/HTTPResponse.py
View file @
1d77cd6c
...
...
@@ -343,7 +343,7 @@ class HTTPResponse(BaseResponse):
self
.
setHeader
(
'content-type'
,
c
)
else
:
c
=
self
.
headers
[
'content-type'
]
if
not
'charset='
in
c
:
if
c
.
startswith
(
'text/'
)
and
not
'charset='
in
c
:
c
=
'%s; charset=%s'
%
(
c
,
default_encoding
)
self
.
setHeader
(
'content-type'
,
c
)
...
...
lib/python/ZPublisher/tests/testHTTPResponse.py
View file @
1d77cd6c
...
...
@@ -94,11 +94,17 @@ class HTTPResponseTests(unittest.TestCase):
self
.
assertEqual
(
response
.
headers
.
get
(
'content-type'
),
'text/plain; charset=iso-8859-15'
)
def
test_charset_application_header
(
self
):
def
test_charset_application_header
_no_header
(
self
):
response
=
self
.
_makeOne
(
body
=
'foo'
,
headers
=
{
'content-type'
:
'application/foo'
})
self
.
assertEqual
(
response
.
headers
.
get
(
'content-type'
),
'application/foo; charset=iso-8859-15'
)
'application/foo'
)
def
test_charset_application_header_with_header
(
self
):
response
=
self
.
_makeOne
(
body
=
'foo'
,
headers
=
{
'content-type'
:
'application/foo; charset: something'
})
self
.
assertEqual
(
response
.
headers
.
get
(
'content-type'
),
'application/foo; charset: something'
)
def
test_charset_application_header_unicode
(
self
):
response
=
self
.
_makeOne
(
body
=
unicode
(
'rger'
,
'iso-8859-15'
),
...
...
@@ -115,6 +121,7 @@ class HTTPResponseTests(unittest.TestCase):
self
.
assertEqual
(
response
.
body
,
unicode
(
'rger'
,
'iso-8859-15'
).
encode
(
'utf-8'
))
def
test_suite
():
suite
=
unittest
.
TestSuite
()
suite
.
addTest
(
unittest
.
makeSuite
(
HTTPResponseTests
,
'test'
))
...
...
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