diff --git a/cheroot/server.py b/cheroot/server.py index bceeb2c95a..cd1cdc75d9 100644 --- a/cheroot/server.py +++ b/cheroot/server.py @@ -209,7 +209,11 @@ def __call__(self, rfile, hdict=None): # noqa: C901 # FIXME if not line.endswith(CRLF): raise ValueError('HTTP requires CRLF terminators') - if line[0] in (SPACE, TAB): + if line[:1] in (SPACE, TAB): + # NOTE: `type(line[0]) is int` and `type(line[:1]) is bytes`. + # NOTE: The former causes a the following warning: + # NOTE: `BytesWarning('Comparison between bytes and int')` + # NOTE: The latter is equivalent and does not. # It's a continuation line. v = line.strip() else: diff --git a/cheroot/test/test_conn.py b/cheroot/test/test_conn.py index b5e9c418f9..38a6245715 100644 --- a/cheroot/test/test_conn.py +++ b/cheroot/test/test_conn.py @@ -53,7 +53,8 @@ def upload(req, resp): "'POST' != request.method %r" % req.environ['REQUEST_METHOD'], ) - return "thanks for '%s'" % req.environ['wsgi.input'].read() + input_contents = req.environ['wsgi.input'].read().decode('utf-8') + return f"thanks for '{input_contents !s}'" def custom_204(req, resp): """Render response with status 204.""" @@ -917,7 +918,7 @@ def test_100_Continue(test_client): status_line, _actual_headers, actual_resp_body = webtest.shb(response) actual_status = int(status_line[:3]) assert actual_status == 200 - expected_resp_body = ("thanks for '%s'" % body).encode() + expected_resp_body = f"thanks for '{body.decode() !s}'".encode() assert actual_resp_body == expected_resp_body conn.close() @@ -987,7 +988,7 @@ def test_readall_or_close(test_client, max_request_body_size): status_line, actual_headers, actual_resp_body = webtest.shb(response) actual_status = int(status_line[:3]) assert actual_status == 200 - expected_resp_body = ("thanks for '%s'" % body).encode() + expected_resp_body = f"thanks for '{body.decode() !s}'".encode() assert actual_resp_body == expected_resp_body conn.close()