spacewander commented on code in PR #8587: URL: https://github.com/apache/apisix/pull/8587#discussion_r1060291836
########## apisix/core/response.lua: ########## @@ -80,7 +115,20 @@ function resp_exit(code, ...) end if idx > 0 then - ngx_print(concat_tab(t, "", 1, idx)) + local response = concat_tab(t, "", 1, idx) + local _, err = decode_json(response) + if not err then + local content_type = ngx_header["Content-type"] + local accept_header = ngx.req.get_headers()["Accept"] Review Comment: We can use https://github.com/apache/apisix/blob/c0c906eb4d62886ffa4b0938b017dc4810cfe639/apisix/core/request.lua#L104 which gets the header from cache ########## apisix/core/response.lua: ########## @@ -80,7 +115,20 @@ function resp_exit(code, ...) end if idx > 0 then - ngx_print(concat_tab(t, "", 1, idx)) + local response = concat_tab(t, "", 1, idx) + local _, err = decode_json(response) Review Comment: It would be more effective to check the header first before decoding, so we can save lots of unnecessary decoding. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: notifications-unsubscr...@apisix.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org