Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
a9ecbdad
Commit
a9ecbdad
authored
Jan 03, 2009
by
Antoine Pitrou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix BytesWarning with -bb in wsgiref.headers.Headers.
parent
35b7e837
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
3 deletions
+8
-3
Lib/test/test_wsgiref.py
Lib/test/test_wsgiref.py
+5
-0
Lib/wsgiref/headers.py
Lib/wsgiref/headers.py
+3
-3
No files found.
Lib/test/test_wsgiref.py
View file @
a9ecbdad
...
...
@@ -426,15 +426,20 @@ class HeaderTests(TestCase):
h
[
b"Foo"
]
=
bytes
(
b"bar"
)
self
.
assertEqual
(
"bar"
,
h
.
get
(
"Foo"
))
self
.
assertEqual
(
"bar"
,
h
.
get
(
b"Foo"
))
h
.
setdefault
(
b"Bar"
,
b"foo"
)
self
.
assertEqual
(
"foo"
,
h
.
get
(
"Bar"
))
self
.
assertEqual
(
"foo"
,
h
.
get
(
b"Bar"
))
h
.
add_header
(
b'content-disposition'
,
b'attachment'
,
filename
=
b'bud.gif'
)
self
.
assertEqual
(
'attachment; filename="bud.gif"'
,
h
.
get
(
"content-disposition"
))
del
h
[
'content-disposition'
]
self
.
assert_
(
b'content-disposition'
not
in
h
)
class
ErrorHandler
(
BaseCGIHandler
):
"""Simple handler subclass for testing BaseHandler"""
...
...
Lib/wsgiref/headers.py
View file @
a9ecbdad
...
...
@@ -73,7 +73,7 @@ class Headers:
Does *not* raise an exception if the header is missing.
"""
name =
name.lower(
)
name =
self._convert_string_type(name.lower()
)
self._headers[:] = [kv for kv in self._headers if kv[0].lower() != name]
def __getitem__(self,name):
...
...
@@ -104,13 +104,13 @@ class Headers:
fields deleted and re-inserted are always appended to the header list.
If no fields exist with the given name, returns an empty list.
"""
name =
name.lower(
)
name =
self._convert_string_type(name.lower()
)
return [kv[1] for kv in self._headers if kv[0].lower()==name]
def get(self,name,default=None):
"""Get the first header value for 'name', or return 'default'"""
name =
name.lower(
)
name =
self._convert_string_type(name.lower()
)
for k,v in self._headers:
if k.lower()==name:
return v
...
...
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