def payload():
 content_type = request.headers.get('Content-Type', '').split(';')[0]
 if (content_type == 'application/json'):
  return request.get_json()
 elif (content_type == 'application/x-www-form-urlencoded'):
  return (multidict_to_dict(request.form) if len(request.form) else abort(400, description='No form-urlencoded data supplied'))
 elif (content_type == 'multipart/form-data'):
  if (len(request.form) or len(request.files)):
   formItems = MultiDict(request.form)
   if config.MULTIPART_FORM_FIELDS_AS_JSON:
    for (key, lst) in formItems.lists():
     new_lst = []
     for value in lst:
      try:
       new_lst.append(json.loads(value))
      except ValueError:
       new_lst.append(json.loads('"{0}"'.format(value)))
     formItems.setlist(key, new_lst)
   payload = CombinedMultiDict([formItems, request.files])
   return multidict_to_dict(payload)
  else:
   abort(400, description='No multipart/form-data supplied')
 else:
  abort(400, description='Unknown or no Content-Type header supplied')

def payload ( ) : content_type = request . headers . get ( 'Content-Type' , '' ) . split ( ';' ) [ 0 ] if ( content_type == 'application/json' ) : return request . get_json ( ) elif ( content_type == 'application/x-www-form-urlencoded' ) : return ( multidict_to_dict ( request . form ) if len ( request . form ) else abort ( 400 , description = 'No form-urlencoded data supplied' ) ) elif ( content_type == 'multipart/form-data' ) : if ( len ( request . form ) or len ( request . files ) ) : formItems = MultiDict ( request . form ) if config . MULTIPART_FORM_FIELDS_AS_JSON : for ( key , lst ) in formItems . lists ( ) : new_lst = [ ] for value in lst : try : new_lst . append ( json . loads ( value ) ) except ValueError : new_lst . append ( json . loads ( '"{0}"' . format ( value ) ) ) formItems . setlist ( key , new_lst ) payload = CombinedMultiDict ( [ formItems , request . files ] ) return multidict_to_dict ( payload ) else : abort ( 400 , description = 'No multipart/form-data supplied' ) else : abort ( 400 , description = 'Unknown or no Content-Type header supplied' )
performs sanity checks or decoding depending on the content-type .