-
New Feature
-
Resolution: Done
-
Normal
-
8.5.0
-
None
-
Security Level: Jimmy
-
None
-
None
Current zkau responses are returned with the header Content-Type:text/plain; charset=utf-8.
Some security / network filtering restrictions require the ability to change the content-type of the response. Ex to "application/json"
Currently, the response type is defined in org.zkoss.zk.au.AuWriters.CONTENT_TYPE
and Used in org.zkoss.zk.au.http.HttpAuWriter .open() and .flush()
If a developer need to change this value, they either have to replace the AuWriters class, or create their own AuWriter implementation (likely copied from HttpAuWriter). Extending HttpAuWriter is not practical, since response.setContentType is called in the middle of the method (can't use super), and private states are used in these methods (can't redefine).
A better solution would be to load content-type from a library property (set to "text/plain;charset=UTF-8" by default). This would allow developers to set their own content-type if necessary.
Note: Since zkau are not always pure JSON, defining application/json will throw warnings on client side. Developers modifying this value should choose the appropriate type for their application and handle an resulting side effect to the client.