[Seaside] Zinc-Seaside: Problem with POSTing UTF-8 JSON
philippe.marschall at gmail.com
Wed Jun 26 16:16:13 UTC 2013
On Wed, Jun 26, 2013 at 12:17 AM, Sven Van Caekenberghe <sven at stfx.eu> wrote:
> Hi Tomas,
> Thanks for the report: this is an important area indeed.
> However, the comment says it: this is intentional, and as far as I know, it is correct. You see, Zinc will correctly decode/encode any HTTP payload, using the supplied mime-type and/or charsets. Seaside is written such that it does not want this: it insists on doing this on its own. That is why ZnZincServerAdaptor is _not_ using the normal request reading code of Zn, but uses a special option to read everything binary. The stupid thing is that even though Seaside needs bytes, it wants them as a String. That is the reason for the otherwise brain dead #asString (and the implicit copy is inefficient as well).
> Of course, you will see your special characters there if you do UTF8 decoding, but that is because you already know what is inside.
> What normally happens, is that later on in the processing, Seaside will access the WARequest payload using proper decoding, using its own framework (much like what Zn would do). AFAIK this whole process works. You can actually test this using some of the functional tests.
> I am not sure that Seaside-REST is doing the right thing (there were some issues with SmalltalkHub as well), but I would think so.
> Are you sure you have set the correct encoding on the adaptor ?
> Are you sure you are posting as application/json;charset=utf-8 and if you do not set the charset, are you sure utf-8 is the default ?
> Are you sure your REST handler and/or JSON parser does the right thing ?
> It is too late right now, but if we want to get further with this, I will need a failing unit test - if these exist in Seaside-REST, but I would assume so. I have no experience running Seaside-REST, I am using Zinc-REST myself, but I would like to learn.
You're right. Seaside-REST doesn't touch the request body. Thomas, can
you check whether you send somewhere #rawBody? If so replace it with
#bodyDecodeUsing:. You can find out encoding from the content type so
it should look something like this:
request bodyDecodeUsing: request contentType charSet
More information about the seaside