kopia lustrzana https://github.com/cirospaciari/socketify.py
fix content-length and transfer-encoding in ASGI and WSGI
rodzic
28cf45d73b
commit
e48d7801c1
|
@ -1,12 +1,15 @@
|
||||||
from flask import Flask
|
from flask import Flask, make_response
|
||||||
from socketify import WSGI
|
from socketify import WSGI
|
||||||
|
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
|
|
||||||
@app.route('/')
|
@app.route('/')
|
||||||
def index():
|
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()
|
||||||
|
|
||||||
|
|
|
@ -286,10 +286,12 @@ class ASGIWebSocket:
|
||||||
|
|
||||||
def write_header(ssl, res, key, value):
|
def write_header(ssl, res, key, value):
|
||||||
if isinstance(key, str):
|
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")
|
key_data = key.encode("utf-8")
|
||||||
elif isinstance(key, bytes):
|
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
|
key_data = key
|
||||||
|
|
||||||
if isinstance(value, int):
|
if isinstance(value, int):
|
||||||
|
|
|
@ -45,10 +45,12 @@ def write_status(ssl, res, status_text):
|
||||||
|
|
||||||
def write_header(ssl, res, key, value):
|
def write_header(ssl, res, key, value):
|
||||||
if isinstance(key, str):
|
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")
|
key_data = key.encode("utf-8")
|
||||||
elif isinstance(key, bytes):
|
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
|
key_data = key
|
||||||
|
|
||||||
if isinstance(value, int):
|
if isinstance(value, int):
|
||||||
|
|
Ładowanie…
Reference in New Issue