Skip to content
This repository was archived by the owner on Jan 13, 2021. It is now read-only.

Commit a9b85f3

Browse files
committed
For python2.7 compatibility
1 parent 89d4227 commit a9b85f3

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

hyper/http20/connection.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from ..common.exceptions import ConnectionResetError
1010
from ..common.bufsocket import BufferedSocket
1111
from ..common.headers import HTTPHeaderMap
12-
from ..common.util import to_host_port_tuple, to_native_string
12+
from ..common.util import to_host_port_tuple, to_native_string, to_bytestring
1313
from ..packages.hyperframe.frame import (
1414
FRAMES, DataFrame, HeadersFrame, PushPromiseFrame, RstStreamFrame,
1515
SettingsFrame, Frame, WindowUpdateFrame, GoAwayFrame, PingFrame,
@@ -179,8 +179,8 @@ def request(self, method, url, body=None, headers={}):
179179
self.putheader(name, value, stream_id, replace=is_default)
180180

181181
# Convert the body to bytes if needed.
182-
if isinstance(body, str):
183-
body = body.encode('utf-8')
182+
if body:
183+
body = to_bytestring(body)
184184

185185
self.endheaders(message_body=body, final=True, stream_id=stream_id)
186186

0 commit comments

Comments
 (0)