RE: Bug in MediaType Parameter handling

2010-02-21 Thread Jerome Louvel
Hi guys,

 

After double checking, there was a bug. Parameters are actually part of the
media type name, so toString() shouldn’t add those parameters again.

 

I’ve fixed the issue in SVN trunk and also improved the behavior of
getParent() to return an instance of MediaType without parameters if
possible first. See test case added:

 

MediaType mediaType = MediaType.valueOf(application/atom+xml;
name=value);

assertEquals(application/atom+xml; name=value,
mediaType.toString());

assertEquals(MediaType.APPLICATION_ATOM, mediaType.getParent());

 

Best regards,
Jerome Louvel
--
Restlet ~ Founder and Technical Lead ~  http://www.restlet.org/
http://www.restlet.org
Noelios Technologies ~  http://www.noelios.com/ http://www.noelios.com

 

 

 

De : Thierry Boileau [mailto:thierry.boil...@noelios.com] 
Envoyé : lundi 25 janvier 2010 12:02
À : discuss@restlet.tigris.org
Objet : Re: Bug in MediaType Parameter handling

 

Hello Carsten,

the current contract of the valueOf method is to use a name such as
application/atom+xml instead of a complete string with the parameters.
In your case, you can use the ContentType constructor with the String
parameter.

Best regards,
Thierry Boileau




Hi,
 
when I do the following:
---
MediaType mediaType = MediaType.valueOf(application/atom+xml;
charset=UTF-8);
System.out.println(mediaType.toString());
---
I get this output (with 2.0M6):
application/atom+xml; charset=UTF-8; charset=UTF-8
 
Seems to be a bug in the handling of parameters.
 
Cheers,
Carsten
 
--
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2441
619 dsMessageId=2441619

--
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2449981

Re: Bug in MediaType Parameter handling

2010-01-25 Thread Thierry Boileau
Hello Carsten,

the current contract of the valueOf method is to use a name such as 
application/atom+xml instead of a complete string with the parameters.
In your case, you can use the ContentType constructor with the String 
parameter.

Best regards,
Thierry Boileau

 Hi,

 when I do the following:
 ---
 MediaType mediaType = MediaType.valueOf(application/atom+xml; 
 charset=UTF-8);
 System.out.println(mediaType.toString());
 ---
 I get this output (with 2.0M6):
 application/atom+xml; charset=UTF-8; charset=UTF-8

 Seems to be a bug in the handling of parameters.

 Cheers,
 Carsten

 --
 http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2441619



--
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2441712