I'm not sure what you mean by "Hitting the JCR directly..." since JCR has
no HTTP support.

In any case, as I said, the ExportServlet doesn't do any special handling
with the content type and the ITs show that application/json is being set,
so I would suggest using a debugger against your instance to see where the
charset is being introduced.

Regards,
Justin

On Wed, Nov 29, 2017 at 7:30 PM Chris Millar <[email protected]> wrote:

> I'm accessing Sling (AEM) directly on port 4502. I can put together a test
> project with Sling and see if it makes a difference.
>
> If you look at the getResponseContentType method [0], you can see this does
> not include the charset.
>
> Is it getting set somewhere else or being defaulted? Hitting the JCR
> directly gives me the correct charset.
>
> Is there no way I can get to the response object to set this in the model?
> Looking at the Impl, it didn't look like it.
>
> [0]
>
> https://sling.apache.org/apidocs/sling9/org/apache/sling/api/SlingHttpServletRequest.html#getResponseContentType
>
> On Wed, Nov 29, 2017 at 5:14 PM, Justin Edelson <[email protected]>
> wrote:
>
> > Hi Chris,
> > Are you sure that the charset is being added by Sling, i.e. are you
> > accessing Sling directly or via an Apache server?
> >
> > The Export Servlet doesn't actually try to infer anything about the
> content
> > type header. It just sets it to request.getResponseContentType(). See
> > [1]. If you trace that back far enough, it ultimately comes from the
> > MimeTypeService which I don't believe would ever include a charset. In
> the
> > ITs this comes back as just application/json.
> >
> > Regards,
> > Justin
> >
> > [1]
> > https://github.com/apache/sling-org-apache-sling-models-
> > impl/blob/master/src/main/java/org/apache/sling/models/
> > impl/ExportServlet.java#L110
> > [2]
> > https://github.com/apache/sling-org-apache-sling-models-
> > integration-tests/blob/master/src/test/java/org/apache/
> > sling/models/testing/exporter/ExporterIT.java#L287
> >
> > On Wed, Nov 29, 2017 at 6:45 PM Chris Millar <[email protected]> wrote:
> >
> > > I've constructed a Sling Model Exporter with very basic options [0],
> and
> > it
> > > seems to be outputting:
> > >
> > > Content-Type: application/json; charset=ISO-8859-1
> > >
> > > This breaks the JSON RFC [1] as the default character encoding. It
> should
> > > be:
> > >
> > > Content-Type: application/json; charset=UTF-8
> > >
> > > I'm hoping there's a solution to this, or that I'm missing something
> > > obvious. Any help is greatly appreciated.
> > >
> > > [0]
> https://gist.github.com/auniverseaway/c8b7b9013b5ecdd9c790253d194d17
> > b6
> > > [1] https://tools.ietf.org/html/rfc7159#section-8.1
> > >
> >
>

Reply via email to