Michael Pasternak has posted comments on this change.
Change subject: restapi: Include charset in JSON Content-Type
......................................................................
Patch Set 3: Code-Review-1
(2 comments)
....................................................
File
backend/manager/modules/restapi/interface/definition/src/main/java/org/ovirt/engine/api/resteasy/json/JsonProvider.java
Line 38: @Produces(MediaType.APPLICATION_JSON)
Line 39: public class JsonProvider extends JacksonJsonProvider {
Line 40: // This is the content type that we will use in all the responses:
Line 41: private static final String CONTENT_TYPE_HEADER = "Content-Type";
Line 42: private static final MediaType CONTENT_TYPE_MEDIA =
MediaType.valueOf(MediaType.APPLICATION_JSON + "; charset=UTF-8");
- how can we be sure that it's always UTF-8?
- what if user asks for another Char-Set (it is supported by RESTeasy and we
may support it one day as well), we will replay with another Char-Set and will
say it's UTF-8 ...
Line 43:
Line 44: public JsonProvider() {
Line 45: // Note that we can't specify here the use of JAXB annotations
as it is ignored if the mapper is changed later,
Line 46: // thus we need to call the parent constructor first, without
a mapper, and then create the mapper and pass it
Line 77: MultivaluedMap<String, Object> httpHeaders, OutputStream
entityStream) throws IOException {
Line 78: // Jackson always generates the output using UTF-8, regardless
of what is requested, so we can safely set the
Line 79: // charset to UTF-8:
Line 80: httpHeaders.putSingle(CONTENT_TYPE_HEADER, CONTENT_TYPE_MEDIA);
Line 81: super.writeTo(value, type, genericType, annotations,
mediaType, httpHeaders, entityStream);
- i wonder why we have to do this manually? you can do it at least by
specifying charset in @Produces [1] and i'm pretty sure there are other infras
making server specifying Char-Set automatically in every reply,
- btw it should also work for xml and yaml (since we should not maintain all
content-type wrappers manually, former is really necessary)
thanks.
[1] @Produces({ "application/json; charset=UTF-8", "application/xml;
charset=UTF-8", "application/yaml; charset=UTF-8" })
Line 82: }
--
To view, visit http://gerrit.ovirt.org/20104
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: comment
Gerrit-Change-Id: I9156fe168451f103219902b821236b5a4703819d
Gerrit-PatchSet: 3
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Juan Hernandez <[email protected]>
Gerrit-Reviewer: Juan Hernandez <[email protected]>
Gerrit-Reviewer: Michael Pasternak <[email protected]>
Gerrit-Reviewer: oVirt Jenkins CI Server
Gerrit-HasComments: Yes
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches