HTTPServerRequest.body should be bytes but it is an empty string that
occurs in Python3 when pass no body to HTTPServerRequest.
self.uri = uri
self.version = version
self.headers = headers or HTTPHeaders()
- self.body = body or ""
+ self.body = body or b""
# set remote IP and protocol
context = getattr(connection, 'context', None)
# more required parameters slip in.
HTTPServerRequest(uri='/')
+ def test_body_is_a_byte_string(self):
+ requets = HTTPServerRequest(uri='/')
+ self.assertIsInstance(requets.body, bytes)
+
class ParseRequestStartLineTest(unittest.TestCase):
METHOD = "GET"
body = environ["wsgi.input"].read(
int(headers["Content-Length"]))
else:
- body = ""
+ body = b""
protocol = environ["wsgi.url_scheme"]
remote_ip = environ.get("REMOTE_ADDR", "")
if environ.get("HTTP_HOST"):