File tree Expand file tree Collapse file tree 1 file changed +8
-8
lines changed Expand file tree Collapse file tree 1 file changed +8
-8
lines changed Original file line number Diff line number Diff line change @@ -133,14 +133,14 @@ async def get_request_args(request: Request) -> dict:
133133 args .update ({k : v .filename if isinstance (v , UploadFile ) else v for k , v in form_data .items ()})
134134 else :
135135 if body_data :
136- json_data = await request .json ()
137- if not isinstance ( json_data , dict ) :
138- json_data = {
139- f' { type (json_data ) } _to_dict_data' : json_data . decode ( 'utf-8' )
140- if isinstance ( json_data , bytes )
141- else json_data
142- }
143- args .update (json_data )
136+ content_type = request .headers . get ( 'Content-Type' , '' ). split ( ';' )[ 0 ]. strip (). lower ()
137+ if content_type == 'application/json' :
138+ json_data = await request . json ()
139+ if isinstance (json_data , bytes ):
140+ json_data = json_data . decode ( 'utf-8' )
141+ args . update ( json_data )
142+ else :
143+ args .update ({ 'body' : str ( body_data )} )
144144 return args
145145
146146 @staticmethod
You can’t perform that action at this time.
0 commit comments