fix content-length and transfer-encoding in ASGI and WSGI

pull/39/head
Ciro 2022-12-04 22:37:14 -03:00
rodzic 28cf45d73b
commit e48d7801c1
3 zmienionych plików z 15 dodań i 8 usunięć

Wyświetl plik

@ -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()

Wyświetl plik

@ -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):

Wyświetl plik

@ -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):