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
97d1453e
Commit
97d1453e
authored
Dec 22, 2002
by
Florent Guillaume
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Merge from Zope-2_6-branch:
Ensured that all HTTP headers are sent as normal strings and not Unicode.
parent
f5c6b791
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
9 deletions
+26
-9
lib/python/OFS/tests/testRanges.py
lib/python/OFS/tests/testRanges.py
+6
-6
lib/python/ZPublisher/HTTPResponse.py
lib/python/ZPublisher/HTTPResponse.py
+20
-3
No files found.
lib/python/OFS/tests/testRanges.py
View file @
97d1453e
...
...
@@ -164,9 +164,9 @@ class TestRequestRange(unittest.TestCase):
self
.
failUnless
(
content_range
==
expect_content_range
,
'Received incorrect Content-Range header. Expected %s, got %s'
%
(
`expect_content_range`
,
`content_range`
))
self
.
failIf
(
rsp
.
getHeader
(
'content-length'
)
!=
len
(
body
),
'Incorrect Content-Length is set! Expected %
d, got %d
.'
%
(
rsp
.
getHeader
(
'content-length'
),
len
(
body
)))
self
.
failIf
(
rsp
.
getHeader
(
'content-length'
)
!=
str
(
len
(
body
)
),
'Incorrect Content-Length is set! Expected %
s, got %s
.'
%
(
str
(
len
(
body
)),
rsp
.
getHeader
(
'content-length'
)))
self
.
failUnless
(
body
==
self
.
data
[
start
:
end
],
'Incorrect range returned, expected %s, got %s'
%
(
...
...
@@ -196,9 +196,9 @@ class TestRequestRange(unittest.TestCase):
"Incorrect Content-Type set. Expected 'multipart/%sbyteranges', "
"got %s"
%
(
draftprefix
,
ct
))
if
rsp
.
getHeader
(
'content-length'
):
self
.
failIf
(
rsp
.
getHeader
(
'content-length'
)
!=
len
(
body
),
'Incorrect Content-Length is set! Expected %
d, got %d
.'
%
(
len
(
body
),
rsp
.
getHeader
(
'content-length'
)))
self
.
failIf
(
rsp
.
getHeader
(
'content-length'
)
!=
str
(
len
(
body
)
),
'Incorrect Content-Length is set! Expected %
s, got %s
.'
%
(
str
(
len
(
body
)
),
rsp
.
getHeader
(
'content-length'
)))
# Decode the multipart message
bodyfile
=
cStringIO
.
StringIO
(
'Content-Type: %s
\
n
\
n
%s'
%
(
...
...
lib/python/ZPublisher/HTTPResponse.py
View file @
97d1453e
...
...
@@ -12,8 +12,8 @@
##############################################################################
'''CGI Response Output formatter
$Id: HTTPResponse.py,v 1.7
1 2002/12/17 00:38:17 andym
Exp $'''
__version__
=
'$Revision: 1.7
1
$'
[
11
:
-
2
]
$Id: HTTPResponse.py,v 1.7
2 2002/12/22 18:31:46 efge
Exp $'''
__version__
=
'$Revision: 1.7
2
$'
[
11
:
-
2
]
import
types
,
os
,
sys
,
re
import
zlib
,
struct
...
...
@@ -233,6 +233,8 @@ class HTTPResponse(BaseResponse):
literal flag is true, the case of the header name is preserved,
otherwise word-capitalization will be performed on the header
name on output.'''
name
=
str
(
name
)
value
=
str
(
value
)
key
=
name
.
lower
()
if
accumulate_header
(
key
):
self
.
accumulated_headers
=
(
...
...
@@ -245,6 +247,8 @@ class HTTPResponse(BaseResponse):
'''
\
Set a new HTTP return header with the given value, while retaining
any previously set headers with the same name.'''
name
=
str
(
name
)
value
=
str
(
value
)
self
.
accumulated_headers
=
(
"%s%s: %s
\
n
"
%
(
self
.
accumulated_headers
,
name
,
value
))
...
...
@@ -429,7 +433,7 @@ class HTTPResponse(BaseResponse):
base
=
''
elif
not
base
.
endswith
(
'/'
):
base
=
base
+
'/'
self
.
base
=
base
self
.
base
=
str
(
base
)
def
insertBase
(
self
,
base_re_search
=
re
.
compile
(
'(<base.*?>)'
,
re
.
I
).
search
...
...
@@ -459,6 +463,9 @@ class HTTPResponse(BaseResponse):
cookie has previously been set in the response object, the new
value is appended to the old one separated by a colon. '''
name
=
str
(
name
)
value
=
str
(
value
)
cookies
=
self
.
cookies
if
cookies
.
has_key
(
name
):
cookie
=
cookies
[
name
]
...
...
@@ -481,6 +488,8 @@ class HTTPResponse(BaseResponse):
when creating the cookie. The path can be specified as a keyword
argument.
'''
name
=
str
(
name
)
dict
=
{
'max_age'
:
0
,
'expires'
:
'Wed, 31-Dec-97 23:59:59 GMT'
}
for
k
,
v
in
kw
.
items
():
dict
[
k
]
=
v
...
...
@@ -495,6 +504,9 @@ class HTTPResponse(BaseResponse):
"value". This overwrites any previously set value for the
cookie in the Response object.
'''
name
=
str
(
name
)
value
=
str
(
value
)
cookies
=
self
.
cookies
if
cookies
.
has_key
(
name
):
cookie
=
cookies
[
name
]
...
...
@@ -511,6 +523,9 @@ class HTTPResponse(BaseResponse):
Sets an HTTP return header "name" with value "value",
appending it following a comma if there was a previous value
set for the header. '''
name
=
str
(
name
)
value
=
str
(
value
)
headers
=
self
.
headers
if
headers
.
has_key
(
name
):
h
=
headers
[
name
]
...
...
@@ -548,6 +563,8 @@ class HTTPResponse(BaseResponse):
self
.
setStatus
(
status
)
self
.
setHeader
(
'Location'
,
location
)
location
=
str
(
location
)
if
lock
:
# Don't let anything change the status code.
# The "lock" argument needs to be set when redirecting
...
...
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