Uploaded image for project: 'ZK'
  1. ZK
  2. ZK-3824

Provide a content-type control for AU response

XMLWordPrintable

    • Icon: New Feature New Feature
    • Resolution: Done
    • Icon: Normal Normal
    • 8.5.2
    • 8.5.0
    • None
    • Security Level: Jimmy
    • 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.

            CharlesQiu CharlesQiu
            MDuchemin MDuchemin
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - 1 day
                1d
                Remaining:
                Time Spent - 2 hours Remaining Estimate - 6 hours
                6h
                Logged:
                Time Spent - 2 hours Remaining Estimate - 6 hours
                2h