[Seaside] Rest and POST method

Philippe Marschall philippe.marschall at gmail.com
Tue Apr 5 07:55:49 UTC 2011


2011/4/5 Olivier Auverlot <olivier.auverlot at gmail.com>:
> Hi Philippe,
>
> I work with the Seaside One-Click image and the HTTP server is Comanche.
>
> *******************************************************
> First test: with form data
> *******************************************************
>
> -- the postForm method --------------------------------
>
> postForm
> <POST>
> <Consumes: 'application/x-www-form-urlencoded'>
> <Path: '/postform'>
>
>    Transcript show: self requestContext request postFields.
>
> -- REQUEST --------------------------------
>
> POST /MonAppRest/postform HTTP/1.1
> Content-Type: application/x-www-form-urlencoded
>
> user=olivier&id=23
>
> -- RESPONSE --------------------------------
>
> HTTP/1.1 200 OK
> Date: Tue, 05 Apr 2011 07:13:01 GMT
> Connection: close
> Server: KomHttpServer/7.1.3 (Mac OS)
> Content-Type: text/html
> Content-Length: 0
>
> -- Result  --------------------------------
> a WARequestFields('id'->'23' 'user'->'olivier')
>
> *******************************************************
> Second test: with XML data
> *******************************************************
>
> -- the postXML method --------------------------------
>
> postXML
>    "detection de l'envoi de données XML"
> <POST>
> <Consumes: 'text/xml'>
> <Path: '/postxml'>
>
>    self requestContext inspect.
>
>    Transcript show: 'postXML'.
>
> -- REQUEST --------------------------------
>
> POST /MonAppRest/postxml HTTP/1.1
> Content-Type: text/xml; charset=utf-8
>
> <?xml version="1.0" encoding="UTF-8"?>
> <agent>
> <nom>auverlot</nom>
> </agent>
>
> -- RESPONSE --------------------------------
>
> HTTP/1.1 200 OK
> Date: Tue, 05 Apr 2011 07:08:01 GMT
> Connection: close
> Server: KomHttpServer/7.1.3 (Mac OS)
> Content-Type: text/html
> Content-Length: 0
>
> -- Result  --------------------------------
> a WARequestFields()
>
> WARequestFields is empty but it seems logical because that is not a form
> that is submited. I tried to read data thru rawBody but it is empty also.
>
> For my project, I need to exchange XML data and probably LDIF data. If there
> are no solutions, I will be forced to use another programming solution (perl
> or java) :-( D'OH!!!.
>
> Do you think that it's possible to implement a mecanism to access of the
> body of a request send with a POST method ?

It should already work ;-)
Can you set a break point in WAComancheRequestConverter >>
#requestBodyFor: and check why the decoding doesn't happen? It could
be because the Content-Length is missing in that case.

Cheers
Philippe


More information about the seaside mailing list