Skip to content

Commit

Permalink
fix: 尝试修复gcsp
Browse files Browse the repository at this point in the history
  • Loading branch information
helloplhm-qwq committed Jun 8, 2024
1 parent c014d8a commit 33bfdf1
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions common/gcsp.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import modules
from .utils import createMD5 as hashMd5
from . import config
from aiohttp.web import Response
from aiohttp.web import Response, Request

PACKAGE = config.read_config("module.gcsp.package_md5") # pkg md5
SALT_1 = config.read_config("module.gcsp.salt_1") # salt 1
Expand Down Expand Up @@ -72,9 +72,15 @@ async def handleGcspBody(body):
else:
return zlib.compress(json.dumps({"code": "403", "error_msg": "内部系统错误,请稍后再试", "data": None}, ensure_ascii = False).encode("utf-8")), 200

async def handle_request(request):
async def handle_request(request: Request):
if (request.method == "POST"):
body = await request.body()
content_size = request.content_length
if (content_size > 5 * 1024): # 5kb
return Response(
body = "Request Entity Too Large",
status = 413
)
body = await request.read()
return Response(
body = await handleGcspBody(body),
content_type = "application/octet-stream"
Expand Down

0 comments on commit 33bfdf1

Please sign in to comment.