Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
nghttp2
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
nghttp2
Commits
add07c43
Commit
add07c43
authored
Feb 25, 2014
by
Tatsuhiro Tsujikawa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
python: Encode headers in UTF-8 if they are given in unicode
parent
4dcb68d1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
7 deletions
+11
-7
python/nghttp2.pyx
python/nghttp2.pyx
+11
-7
No files found.
python/nghttp2.pyx
View file @
add07c43
...
@@ -828,6 +828,7 @@ class BaseRequestHandler:
...
@@ -828,6 +828,7 @@ class BaseRequestHandler:
if
request_headers
is
None
:
if
request_headers
is
None
:
request_headers
=
[]
request_headers
=
[]
request_headers
=
_encode_headers
(
request_headers
)
request_headers
.
append
((
b':scheme'
,
promised_handler
.
scheme
))
request_headers
.
append
((
b':scheme'
,
promised_handler
.
scheme
))
request_headers
.
append
((
b':method'
,
promised_handler
.
method
))
request_headers
.
append
((
b':method'
,
promised_handler
.
method
))
request_headers
.
append
((
b':authority'
,
promised_handler
.
host
))
request_headers
.
append
((
b':authority'
,
promised_handler
.
host
))
...
@@ -839,16 +840,14 @@ class BaseRequestHandler:
...
@@ -839,16 +840,14 @@ class BaseRequestHandler:
def
_set_response_prop
(
self
,
status
,
headers
,
body
):
def
_set_response_prop
(
self
,
status
,
headers
,
body
):
self
.
status
=
status
self
.
status
=
status
self
.
response_headers
=
headers
if
self
.
response_headers
is
None
:
if
headers
is
None
:
self
.
response_headers
=
[]
headers
=
[]
self
.
response_headers
=
_encode_headers
(
headers
)
self
.
response_headers
.
append
((
b':status'
,
str
(
status
).
encode
(
'utf-8'
)))
self
.
response_headers
.
append
((
b':status'
,
str
(
status
).
encode
(
'utf-8'
)))
if
body
:
self
.
response_body
=
body
self
.
response_body
=
io
.
BufferedReader
(
body
)
else
:
self
.
response_body
=
None
def
_wrap_body
(
self
,
body
):
def
_wrap_body
(
self
,
body
):
if
body
is
None
:
if
body
is
None
:
...
@@ -863,6 +862,11 @@ class BaseRequestHandler:
...
@@ -863,6 +862,11 @@ class BaseRequestHandler:
raise
Exception
((
'body must be None or instance of str or bytes '
raise
Exception
((
'body must be None or instance of str or bytes '
'or io.BytesIO'
))
'or io.BytesIO'
))
def
_encode_headers
(
headers
):
return
[(
k
if
isinstance
(
k
,
bytes
)
else
k
.
encode
(
'utf-8'
),
v
if
isinstance
(
v
,
bytes
)
else
v
.
encode
(
'utf-8'
))
\
for
k
,
v
in
headers
]
class
_HTTP2Session
(
asyncio
.
Protocol
):
class
_HTTP2Session
(
asyncio
.
Protocol
):
def
__init__
(
self
,
RequestHandlerClass
):
def
__init__
(
self
,
RequestHandlerClass
):
...
...
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