Hi everybody.
-- I'm trying to learn how to create a restful service by following seaside's book. I implemented method #createJson as indicate in this page: http://book.seaside.st/book/advanced/restful/matching/content-type I'm using curl to simulate a REST client. curl -H "Content-Type: text/json" -d '{"title":"Check out latest Seaside"}' http://localhost:8080/todo-api But the method fails here: JSJsonParser parse: self requestContext request rawBody The body received from the request is always an empty string. Does anybody have any experience with this? I'd appreciate some help. Thanks and regards, Santiago You received this message because you are subscribed to the Google Groups "VA Smalltalk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To post to this group, send email to [hidden email]. Visit this group at http://groups.google.com/group/va-smalltalk. For more options, visit https://groups.google.com/d/optout. |
Ok, I found something (maybe wrong?) in SstHttpServletRequest>>#getPostFieldsString method.
------------------------- SstHttpServletRequest>>#getPostFieldsString "Answer a String built from multipart fields for a post request" | answer | answer := ''. self isPostRequest ifTrue: [ (self getContentTypeOrDefault sameAs: HttpContentTypeFormData ) ifTrue: [ answer := self contents asString ]. (self getContentTypeOrDefault sameAs: HttpContentTypeMultipart) ifTrue: [ answer := self multiPostFields ]]. ^answer ------------------------- The body should be the result of evaluate: self contents asString but self getContentTypeOrDefault is 'application/json' and HttpContentTypeFormData is 'application/x-www-form-urlencoded'. So, neither of the two conditions is met and answer variable keeps '' until the end of the method execution. So my question is: How can I determine if the answer that I need is self contents asString even when the getContentType of the request is different from 'application/x-www-form-urlencoded'? Now I changed the method as follows: ------------------ getPostFieldsString "Answer a String built from multipart fields for a post request" | answer | answer := ''. self isPostRequest ifTrue: [ (self getContentTypeOrDefault sameAs: HttpContentTypeMultipart) ifTrue: [ answer := self multiPostFields ] ifFalse: [ answer := self contents asString ]]. ^answer ------------------ Could this be a permanent fix? El jueves, 25 de junio de 2015, 1:27:26 (UTC-3), Santiago Cardoso Geller escribió: -- You received this message because you are subscribed to the Google Groups "VA Smalltalk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To post to this group, send email to [hidden email]. Visit this group at http://groups.google.com/group/va-smalltalk. For more options, visit https://groups.google.com/d/optout. |
Hello Santiago -
-- Thank you for your analysis. I believe you are correct, but we will need to do a little more checking. I have opened case 52228 for this problem and will post back here with the final resolution. In the meantime, please let us know if your change does not completely correct the situation. Regards, John On Friday, June 26, 2015 at 12:40:27 AM UTC-4, Santiago Cardoso Geller wrote: Ok, I found something (maybe wrong?) in SstHttpServletRequest>># You received this message because you are subscribed to the Google Groups "VA Smalltalk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To post to this group, send email to [hidden email]. Visit this group at http://groups.google.com/group/va-smalltalk. For more options, visit https://groups.google.com/d/optout. |
Thank you John. Regards,I don't know if another Content-Type may produce another issue. I assume that everything that is not multi-part, is the same for this method. I'm only playing with REST and JSON by now and the fix works. Maybe someone with a more complex web application could try the fix. On Thu, Jul 2, 2015 at 9:27 AM, John O'Keefe <[hidden email]> wrote:
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To post to this group, send email to [hidden email]. Visit this group at http://groups.google.com/group/va-smalltalk. For more options, visit https://groups.google.com/d/optout. |
Free forum by Nabble | Edit this page |