/* Copyright (C) 2011, Stephane Bisaro, aka iri License : you can do what you want with this source code This code is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. */ /* Send a POST request to a specific url. INETGetURLex2 is asynchronous, the callback should be defined to get the response INETGetURLex2 = fun [Chn S S S S I fun [INET u0 S I] u1 u0] INET - the channel (S), generally the current channel - the method, generally "POST" - the url - the header, usually "content-type: application/x-www-form-urlencoded" but it can be anything else. - datas to send - an unused argument, should be at 0 - the callback - the user parameter for the calback - return an INET object. */ var myUrl = "http://www.mydomain.tld/post";; var myHeader = "content-type: application/x-www-form-urlencoded";; var myDatas = "arg_1=Bob&arg_2=Alice";; fun CBinet (inet, datas, received, error)= if error == 0 then // transfer in progress ( let datas -> [d] in mutate datas <- [strcat d received]; 0 ) else if error == 1 then // transfer finished ( let datas -> [d] in _createpack d _getmodifypack "examples/network/request_post.html"; _fooS "Done !"; 0 ) else // an error occurs ( _fooS strcat "An error occurs : " itoa error; 0 );; fun main ()= _showconsole; INETGetURLex2 _channel "POST" myUrl myHeader myDatas 0 @CBinet [""]; 0;;