File tree Expand file tree Collapse file tree 1 file changed +9
-14
lines changed
nonebot_plugin_all4one/onebotimpl Expand file tree Collapse file tree 1 file changed +9
-14
lines changed Original file line number Diff line number Diff line change @@ -260,9 +260,11 @@ async def _handle_http(
260260 return response
261261 try :
262262 if request .content :
263- if request .headers .get ("Content-Type" ) == "application/msgpack" :
263+ if (
264+ content_type := request .headers .get ("Content-Type" )
265+ ) == "application/msgpack" :
264266 data = msgpack .unpackb (request .content )
265- elif request . headers . get ( "Content-Type" ) == "application/json" :
267+ elif content_type == "application/json" :
266268 data = json .loads (request .content )
267269 else :
268270 return Response (415 , content = "Invalid Content-Type" )
@@ -274,18 +276,11 @@ async def _handle_http(
274276 )
275277 if "echo" in data :
276278 resp ["echo" ] = data ["echo" ]
277- if request .headers .get ("Content-Type" ) == "application/json" :
278- return Response (
279- 200 ,
280- headers = {"Content-Type" : "application/json" },
281- content = encode_data (resp , False ),
282- )
283- else :
284- return Response (
285- 200 ,
286- headers = {"Content-Type" : "application/msgpack" },
287- content = encode_data (resp , True ),
288- )
279+ return Response (
280+ 200 ,
281+ headers = {"Content-Type" : content_type },
282+ content = encode_data (resp , content_type != "application/json" ),
283+ )
289284 except Exception as e :
290285 logger .debug (e )
291286 return Response (204 )
You can’t perform that action at this time.
0 commit comments