You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@wink.apache.org by "Kaloyan Kolev (JIRA)" <ji...@apache.org> on 2010/03/05 13:01:28 UTC

[jira] Created: (WINK-262) Content-Type of HTTP Response contains no charset.

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.


[jira] Commented: (WINK-262) Content-Type of HTTP Response contains no charset.

Posted by "Nick Gallardo (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WINK-262?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12841840#action_12841840 ] 

Nick Gallardo commented on WINK-262:
------------------------------------

I understand why you have this question and have seen this same issue before in the web services world.  The model with Wink and JAX-RS is that of a framework for allowing users to surface their desired content.  Wink doesn't care what content you send and will surface whatever information you provide.  

In general I agree with Bryant here.  I don't think Wink should be in the game of trying to determine content encodings from user supplied content.  From an execution standpoint, I can't think of a reliable way to do it.  The larger issue is that making such a change would dramatically effect performance of the engine if we were to always read content to determine encoding.





> 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.


[jira] Assigned: (WINK-262) Content-Type of HTTP Response contains no charset.

Posted by "Mike Rheinheimer (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/WINK-262?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Mike Rheinheimer reassigned WINK-262:
-------------------------------------

    Assignee: Mike Rheinheimer

> 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
>            Assignee: Mike Rheinheimer
>             Fix For: 1.1
>
>
> 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.


[jira] Updated: (WINK-262) Content-Type of HTTP Response contains no charset.

Posted by "Mike Rheinheimer (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/WINK-262?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Mike Rheinheimer updated WINK-262:
----------------------------------

    Attachment: WINK-262.patch

Attached patch ought to fix this issue.  Please take a look.  I default to "charset=UTF-8" (note: uppercase) on the response Content-Type header of no "charset" already exists.  However, I did not do it for multipart.  I need some review on this; very strange things were happening in the MultiPartParser under MultiPartTest when I added the default charset.

> 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
>            Assignee: Mike Rheinheimer
>             Fix For: 1.1
>
>         Attachments: WINK-262.patch
>
>
> 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.


[jira] Commented: (WINK-262) Content-Type of HTTP Response contains no charset.

Posted by "Bryant Luk (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WINK-262?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12851002#action_12851002 ] 

Bryant Luk commented on WINK-262:
---------------------------------

My only concern with doing this is we're adding a charset=UTF-8 to all providers even though the parameter does not make any sense (i.e. if they use a byte[] and set the response content to be image/png or something, then the final media type would be image/png;charset=UTF-8).

> 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
>            Assignee: Mike Rheinheimer
>             Fix For: 1.1
>
>         Attachments: WINK-262.patch
>
>
> 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.


[jira] Updated: (WINK-262) Content-Type of HTTP Response contains no charset.

Posted by "Bryant Luk (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/WINK-262?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Bryant Luk updated WINK-262:
----------------------------

    Attachment: WINK-262-2.patch

I propose moving the ;charset addition to the String and XML providers.

The reasoning is because of a few things
1)  Should work on the client and the server
2)  The charset should be in addition to any other handler that's on the path and should be added when providers are invoked directly if possible.

Right now, the basic code block is:

{code}
       if (httpHeaders != null && httpHeaders.get(HttpHeaders.CONTENT_TYPE) == null) {
            // only correct the MediaType if the MediaType was not explicitly
            // set
            logger
                .debug("Media Type not explicitly set on Response so going to correct charset parameter if necessary");//$NON-NLS-1$
            Map<String, String> parameters = mediaType.getParameters();
            if (parameters != null) {
                if (parameters.get("charset") == null) { //$NON-NLS-1$
                    try {
                        Map<String, String> params =
                            new HashMap<String, String>(mediaType.getParameters());
                        params.put("charset", "UTF-8"); //$NON-NLS-1$ $NON-NLS-2$
                        httpHeaders.putSingle(HttpHeaders.CONTENT_TYPE, new MediaType(mediaType
                            .getType(), mediaType.getSubtype(), params)); //$NON-NLS-1$
                        logger.debug("Added charset=UTF-8 parameter to Content-Type HttpHeader"); //$NON-NLS-1$
                    } catch (Exception e) {
                        // this can happen in the Atom Model since we pass in an unmodifiable set
                        logger.debug("Caught exception while trying to set the charset", e); //$NON-NLS-1$
                    }
                }
            }
        }
{code}

The idea is that if a media type is explicitly set by a Response.type() to not change it.  However, if it was populated by the runtime, then go ahead and add the charset if one does not exist.  A few catches for cases where we invoked the provider directly with unexpected parameter values.

> 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
>            Assignee: Mike Rheinheimer
>             Fix For: 1.1
>
>         Attachments: WINK-262-2.patch, WINK-262.patch
>
>
> 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.


[jira] Commented: (WINK-262) Content-Type of HTTP Response contains no charset.

Posted by "Nick Gallardo (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WINK-262?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12841857#action_12841857 ] 

Nick Gallardo commented on WINK-262:
------------------------------------

Just to clarify, you're just wanting Wink to include whatever encoding it used during serialization as the Content-Type header in the response, right?

> 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.


[jira] Updated: (WINK-262) Content-Type of HTTP Response contains no charset.

Posted by "Nick Gallardo (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/WINK-262?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Nick Gallardo updated WINK-262:
-------------------------------

    Fix Version/s: 1.1

> 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
>             Fix For: 1.1
>
>
> 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.


[jira] Commented: (WINK-262) Content-Type of HTTP Response contains no charset.

Posted by "Hudson (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WINK-262?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12851244#action_12851244 ] 

Hudson commented on WINK-262:
-----------------------------

Integrated in Wink-Trunk-JDK1.5 #303 (See [http://hudson.zones.apache.org/hudson/job/Wink-Trunk-JDK1.5/303/])
    : set default charset=UTF-8 when necessary


> 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
>            Assignee: Mike Rheinheimer
>             Fix For: 1.1
>
>         Attachments: WINK-262-2.patch, WINK-262.patch
>
>
> 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.


[jira] Commented: (WINK-262) Content-Type of HTTP Response contains no charset.

Posted by "Kaloyan Kolev (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WINK-262?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12841861#action_12841861 ] 

Kaloyan Kolev commented on WINK-262:
------------------------------------

Right, I think the default serialization encoding missing is what had confused me on the first place.

> 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.


[jira] Commented: (WINK-262) Content-Type of HTTP Response contains no charset.

Posted by "Bryant Luk (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WINK-262?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12851090#action_12851090 ] 

Bryant Luk commented on WINK-262:
---------------------------------

Also, I had to add some test code to correct a problem in the MockServletResponse where the charset was being incorrectly set in the case where the response media type was something like "text/plain;charset=UTF-8;otherParam=value" which I believe is still legal.

> 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
>            Assignee: Mike Rheinheimer
>             Fix For: 1.1
>
>         Attachments: WINK-262-2.patch, WINK-262.patch
>
>
> 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.


[jira] Resolved: (WINK-262) Content-Type of HTTP Response contains no charset.

Posted by "Mike Rheinheimer (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/WINK-262?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Mike Rheinheimer resolved WINK-262.
-----------------------------------

    Resolution: Fixed

Thanks Bryant.  Looks good.  Committed your -2 patch in SVN rev 928969.

> 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
>            Assignee: Mike Rheinheimer
>             Fix For: 1.1
>
>         Attachments: WINK-262-2.patch, WINK-262.patch
>
>
> 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.


[jira] Commented: (WINK-262) Content-Type of HTTP Response contains no charset.

Posted by "Hudson (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WINK-262?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12851267#action_12851267 ] 

Hudson commented on WINK-262:
-----------------------------

Integrated in Wink-Trunk-JDK1.5 #304 (See [http://hudson.zones.apache.org/hudson/job/Wink-Trunk-JDK1.5/304/])
    : followup - consolidate duplicate code into utility method


> 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
>            Assignee: Mike Rheinheimer
>             Fix For: 1.1
>
>         Attachments: WINK-262-2.patch, WINK-262.patch
>
>
> 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.


[jira] Commented: (WINK-262) Content-Type of HTTP Response contains no charset.

Posted by "Bryant Luk (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WINK-262?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12841833#action_12841833 ] 

Bryant Luk commented on WINK-262:
---------------------------------

Would putting Response.ok(e).contentType("application/xml;charset=(your char set)").build() work?

As far as Wink automatically determining the charset, I don't know if that's possible.  We would have to read the entire output and "guess" the character set before we started sending anything in the response (because the charset must be sent as part of the HTTP headers, if we started sending content with a large entity, it may be too late to add/change the HTTP header since the entity data could force a flush of the response to the client).  I'm also not too sure how we could determine the charset correctly (i.e. what if there were conflicts).

Do you have a suggestion on how to determine that?

> 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.


[jira] Work started: (WINK-262) Content-Type of HTTP Response contains no charset.

Posted by "Mike Rheinheimer (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/WINK-262?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Work on WINK-262 started by Mike Rheinheimer.

> 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
>            Assignee: Mike Rheinheimer
>             Fix For: 1.1
>
>
> 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.


[jira] Commented: (WINK-262) Content-Type of HTTP Response contains no charset.

Posted by "Nick Gallardo (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WINK-262?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12841864#action_12841864 ] 

Nick Gallardo commented on WINK-262:
------------------------------------

Got it.  That makes sense.  I see no reason to not include that in the response.  

Marking this for 1.1.

> 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.


[jira] Issue Comment Edited: (WINK-262) Content-Type of HTTP Response contains no charset.

Posted by "Kaloyan Kolev (JIRA)" <ji...@apache.org>.
    [ 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.


[jira] Commented: (WINK-262) Content-Type of HTTP Response contains no charset.

Posted by "Bryant Luk (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WINK-262?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12841838#action_12841838 ] 

Bryant Luk commented on WINK-262:
---------------------------------

Meant Response.ok(e).type("application/xml;charset=(your char set)").build() 

> 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.


[jira] Commented: (WINK-262) Content-Type of HTTP Response contains no charset.

Posted by "Kaloyan Kolev (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WINK-262?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12841855#action_12841855 ] 

Kaloyan Kolev commented on WINK-262:
------------------------------------

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.


[jira] Commented: (WINK-262) Content-Type of HTTP Response contains no charset.

Posted by "Mike Rheinheimer (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WINK-262?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12851022#action_12851022 ] 

Mike Rheinheimer commented on WINK-262:
---------------------------------------

I'd be ok with filtering on the Content-Type to decide if a default charset makes sense or not.  Does that get a little too expensive there, though?  Don't know where it would be any cheaper, performance-wise.

> 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
>            Assignee: Mike Rheinheimer
>             Fix For: 1.1
>
>         Attachments: WINK-262.patch
>
>
> 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.