[ 
https://issues.apache.org/jira/browse/WINK-262?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12841855#action_12841855
 ] 

Kaloyan Kolev edited comment on WINK-262 at 3/5/10 1:39 PM:
------------------------------------------------------------

Specifying the charset using the ResponseBuilder.type() method didn't look very 
good as I don't want to figure out what encoding or what media type the user 
requests in each resource handler - that should be something wink does for me.

This is why I tried providing the Accept request header explicitly and that 
actually did it. I could verify that the specified charset was used to encode 
the content and it was also present in the response Content-Type header.

So this shows that the actual problem is visible when wink cannot detect the 
charset which the message body writer serializes the content with (in my case 
the default is UTF-8). When no charset is detected wink don't add the default 
serialization charset to the Content-Type header when responding.

So do you think that could be enhanced so wink provides the non-ASCII encoding 
as well?

      was (Author: kkolev):
    Specifying the charset using the ResponseBuilder.type() method didn't look 
very good as I don't want to figure out what encoding or what media type the 
user requests in each resource handler - that should be something wink does for 
me.

This is why I tried providing the Accept request header explicitly and that 
actually did it. I could verify that the specified charset was used to encode 
the content and it was also present in the response Content-Type header.

So this shows that the actual problem is visible when wink cannot detect the 
charset which the message body writer serializes the content with (in my case 
the default is UTF-8). When no charset was detected wink don't add it to the 
Content-Type header when responding but still uses non-ASCII for serialization.

So do you think that could be enhanced so wink provides the non-ASCII encoding 
as well?
  
> Content-Type of HTTP Response contains no charset.
> --------------------------------------------------
>
>                 Key: WINK-262
>                 URL: https://issues.apache.org/jira/browse/WINK-262
>             Project: Wink
>          Issue Type: Bug
>          Components: Server
>    Affects Versions: 1.0
>         Environment: Jetty Server 6.1
>            Reporter: Kaloyan Kolev
>
> I have the following handler:
> {code}
> import javax.ws.rs.GET;
> import javax.ws.rs.Path;
> import javax.ws.rs.Produces;
> import javax.ws.rs.core.Context;
> import javax.ws.rs.core.MediaType;
> import javax.ws.rs.core.Request;
> import javax.ws.rs.core.Response;
> import org.apache.wink.common.model.atom.AtomEntry;
> import org.apache.wink.common.model.atom.AtomText;
> @Path("contentType")
> public class ContentTypeTest {
>       @GET
>       @Produces( { MediaType.APPLICATION_XML, MediaType.TEXT_XML, 
> MediaType.APPLICATION_JSON, "text/javascript" })
>       public Response getRepresentation(@Context Request req) {
>               AtomEntry e = new AtomEntry();
>               e.setTitle(new AtomText(
>                               
> "\u5341\u5341\u5341\u5341\u5341\u5341\u5341\u5341\u5341\u5341\u5341\u5341\u4e00\u69cb\u30bd\u30c1\u2010"));
>               return Response.ok(e).build();
>       }
> }
> {code}
> When I open the resource I get the following HTTP response:
> {code}
> Content-Type: application/xml
> Content-Length:       274
> Server:       Jetty(6.1.x)
> {code}
> You can see that the charset is not specified and the content is not properly 
> decoded e.g. by RestClient - http://code.google.com/p/rest-client/
> However I can see that the XML is properly encoded by opening the resource in 
> FF and enforcing UTF-8 decoding.
> Shouldn't wink put the encoding used during serialization if different than 
> ASCII?

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to