http headers & body

Posted by bronco on 04-Oct-2011 15:02

I want to do a http POST (with any client) to webspeed and be able to fetch the entire POST data (the request body) and store it in a, let's say, a longchar. How do I do that?

Access to the http-headers wouldn't hurt either.

Thanks,

Bronco

10.2B05

All Replies

Posted by Admin on 05-Oct-2011 02:29

it mainly depends on the content-type used with the POST request, regular form post uses 'application/x-www-form-urlencoded' in which case you can use get-value like for a GET request... for 'text/xml' the whole post content is treated as XML and loaded in the web-context x-document handle, binary and multi-part file upload is handled by the messenger and depending on configuration gets saved on the web server.

not sure if the messenger got updated lately to know how to handle ajax/json requests like it does for xml

Posted by bronco on 05-Oct-2011 06:04

OK, but what I basically want is to receive a text/plain and be able to access the entire contents at once (to store it in a longchar for example). text/json is supported but then the JSON have to fit in either temp-table or dataset... (like in: htt:read-json("handle", web-context, "merge")).

Posted by Admin on 05-Oct-2011 13:35

although it say 'do not use this' the form-long-input attribute of web-context might be what you are after... never used that though but it might worth a try

Posted by bronco on 06-Oct-2011 04:37

thanks!

Posted by Admin on 06-Oct-2011 04:47

does this means you've tried and is working?

Posted by bronco on 06-Oct-2011 04:55

Yes, one can indeed get the entire message via form-long-input. I'm, however, a bit puzzled by the "do not access this". Probably a codepage thing or so since you basically getting the raw byte message...

For now we can (or better: have to) live with only being able to send valid JSON from a TT or dataset perspective. If I want more I'll wait for OE11 with a decent JSON parser :-)

thank you.

Posted by Admin on 06-Oct-2011 05:38

Yes, one can indeed get the entire message via form-long-input. I'm, however, a bit puzzled by the "do not access this". Probably a codepage thing or so since you basically getting the raw byte message...

indeed the note in documentation does look 'strange', if we're not supposed to use it then why it's even mentioned?

the encoding is most probably utf-8 (default) but you might get it from content-type header as well (if it was specified).

For now we can (or better: have to) live with only being able to send valid JSON from a TT or dataset perspective. If I want more I'll wait for OE11 with a decent JSON parser :-)

or you can get one that just works http://www.ganimede.ro/cms/products/abl-json/

Posted by bronco on 06-Oct-2011 05:47

If we need more (JSON capabilities) than we can get now I'll keep that in mind. Thanks.

This thread is closed