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
020cf240
Commit
020cf240
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
48877964
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
5 deletions
+19
-5
doc/CHANGES.txt
doc/CHANGES.txt
+8
-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
+10
-4
No files found.
doc/CHANGES.txt
View file @
020cf240
...
...
@@ -4,6 +4,14 @@ Zope Changes
Change information for previous versions of Zope can be found in the
file HISTORY.txt.
Zope 2.10.0 (unreleased)
Bugs fixed
- Collector #2208: rewriting/setting the 'charset' part of the content-type
HTTP header will be done only for 'text/*'
Zope 2.10.0 (2006/10/04)
Bugs fixed
...
...
lib/python/ZPublisher/HTTPResponse.py
View file @
020cf240
...
...
@@ -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 @
020cf240
...
...
@@ -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'
),
...
...
@@ -117,9 +123,9 @@ class HTTPResponseTests(unittest.TestCase):
def
test_XMLEncodingRecoding
(
self
):
xml
=
u'<?xml version="1.0" encoding="iso-8859-15" ?>
\
n
<foo><bar/></foo>'
response
=
self
.
_makeOne
(
body
=
xml
,
headers
=
{
'content-type'
:
'
application/foo
; charset=utf-8'
})
response
=
self
.
_makeOne
(
body
=
xml
,
headers
=
{
'content-type'
:
'
text/xml
; charset=utf-8'
})
self
.
assertEqual
(
xml
.
replace
(
'iso-8859-15'
,
'utf-8'
)
==
response
.
body
,
True
)
response
=
self
.
_makeOne
(
body
=
xml
,
headers
=
{
'content-type'
:
'
application/foo
; charset=iso-8859-15'
})
response
=
self
.
_makeOne
(
body
=
xml
,
headers
=
{
'content-type'
:
'
text/xml
; charset=iso-8859-15'
})
self
.
assertEqual
(
xml
==
response
.
body
,
True
)
...
...
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