ruanweihong-aaa opened a new pull request, #14091:
URL: https://github.com/apache/apisix/pull/14091

   ### Description
   
   Locally generated table responses, such as authentication errors, are 
serialized
   as JSON but can be labeled text/plain. Set application/json in the common
   core.response.exit helper after successful serialization, when Content-Type 
is
   unset and HTTP headers have not been sent.
   
   Apply this to a single table body with a numeric status of at least 200 
except
   204 and 304. Exit callbacks use their final body and headers. Explicit types,
   strings, mixed bodies, incremental writes and stream output retain existing
   behavior. HEAD receives corresponding metadata.
   
   The existing body, status, helper signatures and configuration schemas are
   preserved. Accept is not consulted; this adds neither XML/text conversion nor
   Vary: Accept. Related to #8511: this fixes its JSON MIME mismatch only; 
broader
   content negotiation is deferred.
   
   ### Compatibility
   
   The corrected type can change automatic client parsing and MIME-dependent
   filters, including for successful untyped table responses. Empty/cleared 
types
   and Nginx default_type do not prevent automatic typing.
   
   Existing response-rewrite configurations that replace the body with plain 
text
   without setting Content-Type may now return that text as application/json,
   causing JSON parsing failures in clients. Such configurations should also set
   Content-Type to text/plain when replacing the body.
   
   The English and Chinese developer guides and response-rewrite documentation
   explain automatic typing and the body-replacement compatibility requirement.
   
   ### Validation
   
   - 705 assertions passed across 10 regression files covering core responses,
     key-auth, consumer-restriction, exit-transformer, response-rewrite, Admin,
     Control and stream paths.
   - 14 focused core scenarios cover type selection, Accept independence,
     explicit types, callbacks, encoding failure, mixed/string/incremental 
bodies,
     already-sent headers and HEAD/204/304 handling.
   - Full Lua lint (406 files), global-variable checks, test-style checks,
     Markdown lint, git diff --check and patch reverse checks passed.
   
   ### Checklist
   
   - [x] I have explained the need for this PR and the problem it solves
   - [x] I have explained the changes or the new features added to this PR
   - [x] I have added tests corresponding to this change
   - [x] I have updated the documentation to reflect this change
   - [ ] I have verified that this change is backward compatible (If not, 
please discuss on the [APISIX mailing 
list](https://github.com/apache/apisix/tree/master#community) first)
   
   The compatibility checkbox is left unchecked because the response type change
   can affect existing consumers, as described above.


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to