Well I guess this would then do the trick: requestBodyFor: aZincRequest ^ String streamContents: [ :stream | aZincRequest entity writeOn: (ZnBivalentWriteStream on: stream) ] but it hurts: at this point Zn has already parsed/interpreted the entity from bytes and the above code reencodes it again to bytes. That is why I asked if this is needed in all cases, I guess the body will not be used later on if it is either application/x-www-form-urlencoded or multipart/form-data (since these are handled in #requestFieldsFor:). If that is true, a faster fallback based on #contents should be possible (but with some ugly tests). Also a guard testing for entity #isEmpty and non-POST requests will probably be more efficient. Should I try to write a version and commit it ? Sven On 20 Nov 2011, at 20:35, Lukas Renggli wrote:
Given the current implementation:
requestBodyFor: aZincRequest ^ aZincRequest entity
you get a ZnEntity subclass back, not a String which WARequest>>#setBody: seems to expect.
As you certainly known, many different kinds of things could be uploaded in a POST, depending on the mime type, some of the important ones are in the subclasses of ZnEntity. I don't think a general conversion to String is possible, unless the idea is that that String should contain the byte representation of what got posted.
Seaside expects a string containing the byte representation of what got posted.
The #contents method does try to return something useful (sometimes higher level Smalltalk objects).
BTW, what is the difference between #requestBodyFor: and #requestFieldsFor: ?
Have a look at the Kom adaptor:
requestFieldsFor: aNativeRequest | fields | fields := WARequestFields new. aNativeRequest isPostRequest ifTrue: [ self postFieldsOf: aNativeRequest into: fields ]. ^ fields
requestBodyFor: aNativeRequest ^ aNativeRequest rawRequestContents
Lukas