[Seaside] Zinc-Seaside: Problem with POSTing UTF-8 JSON

Tomas Kukol tomas.kukol at gmail.com
Wed Jun 26 20:35:22 UTC 2013


Hello, guys. Thanks for a great help.

I created these methods to check it:

GPRestfulHandler(WARestfulHandler)>>executeResult: aRouteResult
| result |
self requestContext
respond: [ :response |
result := aRouteResult sendMessageTo: self.
response document: result mimeType: aRouteResult seasideMimeType ]

1) First one with simple Czech string:

GPRestfulHandler(WARestfulHandler)>>czechTestReal
<get>
<path: 'czechTestReal'>
<produces: 'application/json; charset=utf-8'>
^ 'Czech is in Czech čeština.' asJson

2) Second one with simple ascii string:

GPRestfulHandler(WARestfulHandler)>>czechTestReal
<get>
<path: 'czechTestReal'>
<produces: 'application/json; charset=utf-8'>
^ 'Czech is in Czech cestina.' asJson

1) In first case in executeResult: method in result variable is
WideString 'Czech
is in Czech čeština.'

I can see on the screen this error although I have WAException filter set
to WAWalbackErrorHandler.

Error: Improper store into indexable object

2) In second case in executeResult: method in result variable is
ByteString 'Czech is in Czech cestina.'

I can see on the screen expected result:

"Czech is in Czech cestina."

So, there must be somewhere a difference between ByteString and
WideString conversion. I located the problem (thrown error) in this
method:

ZnZincServerAdaptor>>responseFrom: aRequestContext

	| partialHeaders cookies fullHeaders seasideResponse contents entity
contentType |
	seasideResponse := aRequestContext response.
	partialHeaders := seasideResponse headers.
	cookies := seasideResponse cookies.
	fullHeaders := ZnHeaders defaultResponseHeaders.
	partialHeaders keysAndValuesDo: [ :key :value |
		fullHeaders at: key put: value ].
	cookies do: [ :each |
		fullHeaders at: 'Set-Cookie' add: each oldNetscapeString.
		fullHeaders at: 'Set-Cookie2' add: each rfc2965String ].
	contentType := seasideResponse contentType greaseString.
	contents := seasideResponse contents. "<------------------------ HERE
is the error signalled"
	entity := (ZnEntity bytes: contents) contentType: contentType; yourself.
	^ ZnResponse new
		statusLine: (ZnStatusLine code: seasideResponse status);
		headers: fullHeaders;
		entity: entity;
		yourself

Regards,
Tomas



On Wed, Jun 26, 2013 at 7:28 PM, Sven Van Caekenberghe <sven at stfx.eu> wrote:

>
> On 26 Jun 2013, at 18:47, Philippe Marschall <philippe.marschall at gmail.com>
> wrote:
>
> > On Wed, Jun 26, 2013 at 6:37 PM, Sven Van Caekenberghe <sven at stfx.eu>
> wrote:
> >> Tomas,
> >>
> >> I am not sure what one is supposed to return from #getUsers.
> >>
> >> Naively, I would guess just a [Wide]String with the <produces:
> 'application/json; charset=utf-8'> telling the Seaside-REST framework to do
> the right thing, but I just don't know.
> >
> > Yes it does/should, see
> >
> > WARestfulHandler/Filter >> #executeResult:
>
> I see. Tomas, can you trace in there and see what happens in your case ?
>
> > Cheers
> > Philippe
> > _______________________________________________
> > seaside mailing list
> > seaside at lists.squeakfoundation.org
> > http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>
> _______________________________________________
> seaside mailing list
> seaside at lists.squeakfoundation.org
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/seaside/attachments/20130626/3190306e/attachment.htm


More information about the seaside mailing list