[Seaside] Error in Seaside-REST-Core-Route - WARouteBuilder>>produces: method?

Philippe Marschall philippe.marschall at gmail.com
Thu Aug 16 07:49:38 UTC 2012


On Wed, Aug 15, 2012 at 6:43 PM, Tomas Kukol <tomas.kukol at gmail.com> wrote:
> Hi everybody.
>
> I have found an error in WARouteBuilder>>produces: method in
> Seaside-REST-Core-Route category in package SeasideRest version 0.22.
>
> There is a following code:
>
> WARouteBuilder>>produces: aString
>         <configuration>
>
>         produces := WAMimeTypeMatch fromString: aString
>
> I think that there should be this code:
>
> WARouteBuilder>>produces: aString
>         <configuration>
>
>         produces := WAMimeType fromString: aString
>
> If I understand it well, WAMimeTypeMatch is used for matching of the
> request. So it supports only "main" and "sub" from MIME, for example
> "text/json", and not parameters after ";" character as in "text/json;
> charset=UTF-8". In this case the parameters part "charset=UTF-8" is
> lost when used in pragma "produces" in REST filter.
>
> It seems to me that "produces" is used for response where the whole
> MIME with parameters makes sense.
>
> Am I right? Could you correct it?

I think you discovered an issue but I think the solution should be
different. Let me elaborate. The pragma is used to do content
negation, mainly to pick the method that produces the content that
most closely matches the user agents preferences.

Assume you have the following HTTP request header:

Accept: text/xml; q=0.5, text/plain; q=0.1

And the following two methods:

xml
  <produces: 'text/xml'>

text
  <produces: 'text/plain'>

Seaside-REST would then pick the #xml method. Now per default we set
the mime type of the response and lose the encoding as you report. We
should set that but we should read it from the request context /
server adapter instead of the method [1]. You don't want to hard code
it in the method.

 [1] http://code.google.com/p/seaside/issues/detail?id=738

Cheers
Philippe


More information about the seaside mailing list