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
7596da86
Commit
7596da86
authored
Dec 21, 2005
by
Andreas Jung
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
more tests and fixes
parent
14923f9b
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
1 deletion
+29
-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
+23
-0
No files found.
lib/python/ZPublisher/HTTPResponse.py
View file @
7596da86
...
@@ -333,13 +333,18 @@ class HTTPResponse(BaseResponse):
...
@@ -333,13 +333,18 @@ class HTTPResponse(BaseResponse):
self
.
body
=
body
self
.
body
=
body
if
not
self
.
headers
.
has_key
(
'content-type'
):
isHTML
=
self
.
isHTML
(
self
.
body
)
isHTML
=
self
.
isHTML
(
self
.
body
)
if
not
self
.
headers
.
has_key
(
'content-type'
):
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 @
7596da86
# -*- coding: iso-8859-15 -*-
import
unittest
import
unittest
class
HTTPResponseTests
(
unittest
.
TestCase
):
class
HTTPResponseTests
(
unittest
.
TestCase
):
...
@@ -74,6 +76,27 @@ class HTTPResponseTests(unittest.TestCase):
...
@@ -74,6 +76,27 @@ 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_CharsetApplicationHeaderUnicode
(
self
):
response
=
self
.
_makeOne
(
body
=
unicode
(
'rger'
,
'iso-8859-15'
),
headers
=
{
'content-type'
:
'application/foo'
})
self
.
assertEqual
(
response
.
headers
.
get
(
'content-type'
),
'application/foo; charset=iso-8859-15'
)
self
.
assertEqual
(
response
.
body
,
'rger'
)
def
test_CharsetApplicationHeader1Unicode
(
self
):
response
=
self
.
_makeOne
(
body
=
unicode
(
'rger'
,
'iso-8859-15'
),
headers
=
{
'content-type'
:
'application/foo; charset=utf-8'
})
self
.
assertEqual
(
response
.
headers
.
get
(
'content-type'
),
'application/foo; charset=utf-8'
)
self
.
assertEqual
(
response
.
body
,
unicode
(
'rger'
,
'iso-8859-15'
).
encode
(
'utf-8'
))
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