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
77a95049
Commit
77a95049
authored
Dec 21, 2005
by
Andreas Jung
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixes + more tests (Stefan Holek)
parent
6764040e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
1 deletion
+17
-1
lib/python/ZPublisher/HTTPResponse.py
lib/python/ZPublisher/HTTPResponse.py
+6
-1
lib/python/ZPublisher/tests/testHTTPResponse.py
lib/python/ZPublisher/tests/testHTTPResponse.py
+11
-0
No files found.
lib/python/ZPublisher/HTTPResponse.py
View file @
77a95049
...
@@ -333,13 +333,18 @@ class HTTPResponse(BaseResponse):
...
@@ -333,13 +333,18 @@ class HTTPResponse(BaseResponse):
self
.
body
=
body
self
.
body
=
body
isHTML
=
self
.
isHTML
(
self
.
body
)
if
not
self
.
headers
.
has_key
(
'content-type'
):
if
not
self
.
headers
.
has_key
(
'content-type'
):
isHTML
=
self
.
isHTML
(
self
.
body
)
if
isHTML
:
if
isHTML
:
c
=
'text/html; charset=%s'
%
default_encoding
c
=
'text/html; charset=%s'
%
default_encoding
else
:
else
:
c
=
'text/plain; charset=%s'
%
default_encoding
c
=
'text/plain; charset=%s'
%
default_encoding
self
.
setHeader
(
'content-type'
,
c
)
self
.
setHeader
(
'content-type'
,
c
)
else
:
c
=
self
.
headers
[
'content-type'
]
if
not
'charset='
in
c
:
c
=
'%s; charset=%s'
%
(
c
,
default_encoding
)
self
.
setHeader
(
'content-type'
,
c
)
# Some browsers interpret certain characters in Latin 1 as html
# Some browsers interpret certain characters in Latin 1 as html
# special characters. These cannot be removed by html_quote,
# special characters. These cannot be removed by html_quote,
...
...
lib/python/ZPublisher/tests/testHTTPResponse.py
View file @
77a95049
...
@@ -74,6 +74,17 @@ class HTTPResponseTests(unittest.TestCase):
...
@@ -74,6 +74,17 @@ class HTTPResponseTests(unittest.TestCase):
response
.
appendHeader
(
'XXX'
,
'foo'
)
response
.
appendHeader
(
'XXX'
,
'foo'
)
self
.
assertEqual
(
response
.
headers
.
get
(
'xxx'
),
'bar,
\
n
\
t
foo'
)
self
.
assertEqual
(
response
.
headers
.
get
(
'xxx'
),
'bar,
\
n
\
t
foo'
)
def
test_CharsetNoHeader
(
self
):
response
=
self
.
_makeOne
(
body
=
'foo'
)
self
.
assertEqual
(
response
.
headers
.
get
(
'content-type'
),
'text/plain; charset=iso-8859-15'
)
def
test_CharsetTextHeader
(
self
):
response
=
self
.
_makeOne
(
body
=
'foo'
,
headers
=
{
'content-type'
:
'text/plain'
})
self
.
assertEqual
(
response
.
headers
.
get
(
'content-type'
),
'text/plain; charset=iso-8859-15'
)
def
test_CharsetApplicationHeader
(
self
):
response
=
self
.
_makeOne
(
body
=
'foo'
,
headers
=
{
'content-type'
:
'application/foo'
})
self
.
assertEqual
(
response
.
headers
.
get
(
'content-type'
),
'application/foo; charset=iso-8859-15'
)
def
test_suite
():
def
test_suite
():
suite
=
unittest
.
TestSuite
()
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