def create_post_response(self, request, result): response = Response() accepts_gzip = 0 try: if request.environ.get("HTTP_ACCEPT_ENCODING").find("gzip") != -1: accepts_gzip = 1 except: pass buff = json.dumps(result, default=common.json_defaul_handler) response.headers['Content-Type'] = 'application/json' if accepts_gzip: buff = common.compressBuf(buff) response.headers['Content-encoding'] = 'gzip' response.headers['Content-Length'] = str(len(buff)) response.set_data(buff) return response
def create_post_response(self, request, result): response = Response() accepts_gzip = 0 try: if request.environ.get("HTTP_ACCEPT_ENCODING").find("gzip") != -1: accepts_gzip = 1 except: pass try: buff = json.dumps(result, default=common.json_defaul_handler) except: print('wsgi.py create_post_response error:') print(result) raise response.headers['Content-Type'] = 'application/json' if accepts_gzip: buff = common.compressBuf(buff) response.headers['Content-encoding'] = 'gzip' response.headers['Content-Length'] = str(len(buff)) response.set_data(buff) return response