diff --git a/bench/asgi_wsgi/flask-wsgi.py b/bench/asgi_wsgi/flask-wsgi.py index 00c6f8d..84cb118 100644 --- a/bench/asgi_wsgi/flask-wsgi.py +++ b/bench/asgi_wsgi/flask-wsgi.py @@ -1,12 +1,15 @@ -from flask import Flask +from flask import Flask, make_response from socketify import WSGI app = Flask(__name__) @app.route('/') def index(): - return 'Hello, World!' + """Test 6: Plaintext""" + response = make_response(b"Hello, World!") + response.content_type = "text/plain" + return response -def run_app(): - WSGI(app, request_response_factory_max_itens=200_000).listen(8000, lambda config: print(f"Listening on port http://localhost:{config.port} now\n")).run() + +WSGI(app).listen(8000, lambda config: print(f"Listening on port http://localhost:{config.port} now\n")).run() diff --git a/src/socketify/asgi.py b/src/socketify/asgi.py index 8c458c0..8b2c8dc 100644 --- a/src/socketify/asgi.py +++ b/src/socketify/asgi.py @@ -286,10 +286,12 @@ class ASGIWebSocket: def write_header(ssl, res, key, value): if isinstance(key, str): - if key == "content-length": return #auto + if key.lower() == "content-length": return #auto + if key.lower() == "transfer-encoding": return #auto key_data = key.encode("utf-8") elif isinstance(key, bytes): - if key == b'content-length': return #auto + if key.lower() == b'content-length': return #auto + if key.lower() == b'transfer-encoding': return #auto key_data = key if isinstance(value, int): diff --git a/src/socketify/wsgi.py b/src/socketify/wsgi.py index 12a3fb1..f737679 100644 --- a/src/socketify/wsgi.py +++ b/src/socketify/wsgi.py @@ -45,10 +45,12 @@ def write_status(ssl, res, status_text): def write_header(ssl, res, key, value): if isinstance(key, str): - if key == "content-length": return #auto + if key.lower() == "content-length": return #auto + if key.lower() == "transfer-encoding": return #auto key_data = key.encode("utf-8") elif isinstance(key, bytes): - if key == b'content-length': return #auto + if key.lower() == b'content-length': return #auto + if key.lower() == b'transfer-encoding': return #auto key_data = key if isinstance(value, int):