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
46a537db
Commit
46a537db
authored
Jun 21, 2006
by
Tres Seaver
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Collector #2136: Map ResourceLockedError to the correct response code.
parent
167ca2ee
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
18 deletions
+36
-18
lib/python/ZPublisher/HTTPResponse.py
lib/python/ZPublisher/HTTPResponse.py
+1
-0
lib/python/ZPublisher/tests/testHTTPResponse.py
lib/python/ZPublisher/tests/testHTTPResponse.py
+35
-18
No files found.
lib/python/ZPublisher/HTTPResponse.py
View file @
46a537db
...
@@ -97,6 +97,7 @@ for name in en:
...
@@ -97,6 +97,7 @@ for name in en:
status_codes
[
'nameerror'
]
=
503
status_codes
[
'nameerror'
]
=
503
status_codes
[
'keyerror'
]
=
503
status_codes
[
'keyerror'
]
=
503
status_codes
[
'redirect'
]
=
300
status_codes
[
'redirect'
]
=
300
status_codes
[
'resourcelockederror'
]
=
423
start_of_header_search
=
re
.
compile
(
'(<head[^>]*>)'
,
re
.
IGNORECASE
).
search
start_of_header_search
=
re
.
compile
(
'(<head[^>]*>)'
,
re
.
IGNORECASE
).
search
...
...
lib/python/ZPublisher/tests/testHTTPResponse.py
View file @
46a537db
...
@@ -51,7 +51,8 @@ class HTTPResponseTests(unittest.TestCase):
...
@@ -51,7 +51,8 @@ class HTTPResponseTests(unittest.TestCase):
# Verify that the cookie is expired even if an expires kw arg is passed
# Verify that the cookie is expired even if an expires kw arg is passed
# http://zope.org/Collectors/Zope/1160
# http://zope.org/Collectors/Zope/1160
response
=
self
.
_makeOne
()
response
=
self
.
_makeOne
()
response
.
expireCookie
(
'foo'
,
path
=
'/'
,
expires
=
'Mon, 22-Mar-2004 17:59 GMT'
,
max_age
=
99
)
response
.
expireCookie
(
'foo'
,
path
=
'/'
,
expires
=
'Mon, 22-Mar-2004 17:59 GMT'
,
max_age
=
99
)
cookie
=
response
.
cookies
.
get
(
'foo'
,
None
)
cookie
=
response
.
cookies
.
get
(
'foo'
,
None
)
self
.
failUnless
(
cookie
)
self
.
failUnless
(
cookie
)
self
.
assertEqual
(
cookie
.
get
(
'expires'
),
'Wed, 31-Dec-97 23:59:59 GMT'
)
self
.
assertEqual
(
cookie
.
get
(
'expires'
),
'Wed, 31-Dec-97 23:59:59 GMT'
)
...
@@ -76,27 +77,43 @@ class HTTPResponseTests(unittest.TestCase):
...
@@ -76,27 +77,43 @@ 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
):
def
test_setStatus_ResourceLockedError
(
self
):
response
=
self
.
_makeOne
(
body
=
'foo'
)
response
=
self
.
_makeOne
()
self
.
assertEqual
(
response
.
headers
.
get
(
'content-type'
),
'text/plain; charset=iso-8859-15'
)
from
webdav.Lockable
import
ResourceLockedError
response
.
setStatus
(
ResourceLockedError
)
def
test_CharsetTextHeader
(
self
):
self
.
assertEqual
(
response
.
status
,
423
)
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
):
def
test_charset_no_header
(
self
):
response
=
self
.
_makeOne
(
body
=
'foo'
,
headers
=
{
'content-type'
:
'application/foo'
})
response
=
self
.
_makeOne
(
body
=
'foo'
)
self
.
assertEqual
(
response
.
headers
.
get
(
'content-type'
),
'application/foo; charset=iso-8859-15'
)
self
.
assertEqual
(
response
.
headers
.
get
(
'content-type'
),
'text/plain; charset=iso-8859-15'
)
def
test_charset_text_header
(
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_charset_application_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'
)
def
test_CharsetApplicationHeaderUnicode
(
self
):
def
test_charset_application_header_unicode
(
self
):
response
=
self
.
_makeOne
(
body
=
unicode
(
'rger'
,
'iso-8859-15'
),
headers
=
{
'content-type'
:
'application/foo'
})
response
=
self
.
_makeOne
(
body
=
unicode
(
'rger'
,
'iso-8859-15'
),
self
.
assertEqual
(
response
.
headers
.
get
(
'content-type'
),
'application/foo; charset=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'
)
self
.
assertEqual
(
response
.
body
,
'rger'
)
def
test_CharsetApplicationHeader1Unicode
(
self
):
def
test_charset_application_header_unicode_1
(
self
):
response
=
self
.
_makeOne
(
body
=
unicode
(
'rger'
,
'iso-8859-15'
),
headers
=
{
'content-type'
:
'application/foo; charset=utf-8'
})
response
=
self
.
_makeOne
(
body
=
unicode
(
'rger'
,
'iso-8859-15'
),
self
.
assertEqual
(
response
.
headers
.
get
(
'content-type'
),
'application/foo; charset=utf-8'
)
headers
=
{
'content-type'
:
'application/foo; charset=utf-8'
})
self
.
assertEqual
(
response
.
body
,
unicode
(
'rger'
,
'iso-8859-15'
).
encode
(
'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_XMLEncodingRecoding
(
self
):
def
test_XMLEncodingRecoding
(
self
):
xml
=
u'<?xml version="1.0" encoding="iso-8859-15" ?>
\
n
<foo><bar/></foo>'
xml
=
u'<?xml version="1.0" encoding="iso-8859-15" ?>
\
n
<foo><bar/></foo>'
...
...
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