def doFilter(self, request: Request, response: Response, chain: FilterChain): if request.headers['Content-Type'] == 'application/json' and len(request.body) > 0: request.body = json.loads(request.body) chain.doFilter(request, response) if isinstance(response.body, dict) or isinstance(response.body, list): response.body = json.dumps(response.body) response.headers['Content-Type'] = 'application/json'
def doFilter(self, request: Request, response: Response, chain: FilterChain): if request.headers['Content-Type'] == 'application/x-www-form-urlencoded': request.body = parse_urlencoded_form(request.body.decode("utf-8")) chain.doFilter(request, response)