pharo-users@lists.pharo.org

Any question about pharo is welcome

View all threads

Reading http post data using Zinc

DV
Davide Varvello
Wed, Jun 16, 2021 9:17 PM

Hi Guys,
I'm posting from an http form and I'm wondering how to read data from the
post. It seems the request should give a ZnMultiPartFormDataEntity, but I
can't find how to use it.

Can you help me please?
Davide

--
Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html

Hi Guys, I'm posting from an http form and I'm wondering how to read data from the post. It seems the request should give a ZnMultiPartFormDataEntity, but I can't find how to use it. Can you help me please? Davide -- Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html
SV
Sven Van Caekenberghe
Wed, Jun 16, 2021 9:32 PM

Hi Davide,

On 16 Jun 2021, at 23:17, Davide Varvello via Pharo-users pharo-users@lists.pharo.org wrote:

Hi Guys,
I'm posting from an http form and I'm wondering how to read data from the
post. It seems the request should give a ZnMultiPartFormDataEntity, but I
can't find how to use it.

Can you help me please?
Davide

--
Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html

It depends on how the form is posted (there are two approaches).

A working example of both can be found in ZnDefaultServerDelegate>>#formTest2: and #formTest3:

ZnServerTest>>#testFormTest2: and #testFormTest3: exercise this functionality

Basically, you just take the entity from the request and use it.

HTH,

Sven

Hi Davide, > On 16 Jun 2021, at 23:17, Davide Varvello via Pharo-users <pharo-users@lists.pharo.org> wrote: > > Hi Guys, > I'm posting from an http form and I'm wondering how to read data from the > post. It seems the request should give a ZnMultiPartFormDataEntity, but I > can't find how to use it. > > Can you help me please? > Davide > > > > > -- > Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html It depends on how the form is posted (there are two approaches). A working example of both can be found in ZnDefaultServerDelegate>>#formTest2: and #formTest3: ZnServerTest>>#testFormTest2: and #testFormTest3: exercise this functionality Basically, you just take the entity from the request and use it. HTH, Sven
DV
Davide Varvello
Thu, Jun 17, 2021 9:37 AM

Hi Sven,
I'm sending a FormData, so the right code is in
ZnDefaultServerDelegate>>#formTest3: that you pointed out. Thank you very
much.

To help other people of the list, I summarize that in case of multipart
form-data you have to read the entity and its parts, for example:
(aRequest entity partNamed: #myPartName) fieldValueString.

or also:
aRequest entity parts first fieldName.
aRequest entity parts first fieldValue

Cheers
Davide

Sven Van Caekenberghe-2 wrote

Hi Davide,

On 16 Jun 2021, at 23:17, Davide Varvello via Pharo-users <

pharo-users@.pharo

> wrote:

Hi Guys,
I'm posting from an http form and I'm wondering how to read data from the
post. It seems the request should give a ZnMultiPartFormDataEntity, but I
can't find how to use it.

Can you help me please?
Davide

--
Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html

It depends on how the form is posted (there are two approaches).

A working example of both can be found in
ZnDefaultServerDelegate>>#formTest2: and #formTest3:

ZnServerTest>>#testFormTest2: and #testFormTest3: exercise this
functionality

Basically, you just take the entity from the request and use it.

HTH,

Sven

Hi Sven, I'm sending a FormData, so the right code is in ZnDefaultServerDelegate>>#formTest3: that you pointed out. Thank you very much. To help other people of the list, I summarize that in case of multipart form-data you have to read the entity and its parts, for example: (aRequest entity partNamed: #myPartName) fieldValueString. or also: aRequest entity parts first fieldName. aRequest entity parts first fieldValue Cheers Davide Sven Van Caekenberghe-2 wrote > Hi Davide, > >> On 16 Jun 2021, at 23:17, Davide Varvello via Pharo-users &lt; > pharo-users@.pharo > &gt; wrote: >> >> Hi Guys, >> I'm posting from an http form and I'm wondering how to read data from the >> post. It seems the request should give a ZnMultiPartFormDataEntity, but I >> can't find how to use it. >> >> Can you help me please? >> Davide >> >> >> >> >> -- >> Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html > > It depends on how the form is posted (there are two approaches). > > A working example of both can be found in > ZnDefaultServerDelegate>>#formTest2: and #formTest3: > > ZnServerTest>>#testFormTest2: and #testFormTest3: exercise this > functionality > > Basically, you just take the entity from the request and use it. > > HTH, > > Sven -- Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html