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

Provide a content-type control for AU response

    Details

    • Type: New Feature
    • Status: Closed
    • Priority: Normal
    • Resolution: Done
    • Affects Version/s: 8.5.0
    • Fix Version/s: 8.5.2
    • Component/s: None
    • Security Level: Jimmy
    • Labels:
      None
    • Environment:

      Description

      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.

        Activity

        Hide
        Anonymous added a comment -

        Ready since 2018/06/13

        Show
        Anonymous added a comment - Ready since 2018/06/13
        Show
        CharlesQiu CharlesQiu added a comment - https://www.zkoss.org/wiki/ZK_Configuration_Reference/zk.xml/The_Library_Properties/org.zkoss.zk.au.AuWriters.ContentType

          People

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

            Dates

            • Created:
              Updated:
              Resolved:

              Time Tracking

              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