Project

General

Profile

Up

INETGetURLex2

Send a http request to a specific url with a specific verb (which would probably be POST). This is asynchronous. When server responds, the callback is fired, with following arguments.

  • a connection object (INET)
  • an user parameter at your convenience (u0)
  • the data parameter : depends on the following parameter
  • the state code :
    • 0 : some data has been received, and can be read in the received data parameter
    • 1 : end of request. received data is nil. This is the last call of the callback.
    • other : an error occured during the request. received data is nil. This is the last call of the callback

Prototype :

fun [Chn S S S S I fun [INET u0 S I] u1 u0] INET

  • Chn : a channel
  • S : verb, like "POST", "GET", "PUT" ...
  • S : url
  • S : header, if requested
  • S : content to send
  • I : should be 0
  • fun [INET u0 S I] u1 : reflex
  • u0 : user parameter, at your convenience

Return : INET a connection object or nil if error

See also :

Example :

fun send_callback (inet, user_param, data, err)=
	if err == 0 then	// the response is not finished
		// to do something
	else if err == 1 then	// the response is ok and finished
		// to do something
	else		// an error occurs
		// to do something
	0;;

fun send_request (address, verb, param)=
	INETGetURLex2 
		_channel 
		verb	// "POST", "GET", "HEAD", ...
		address
		"content-type: application/x-www-form-urlencoded"	// request header, if any
		param	// content to send
		0	// should stay at 0
		@send_callback	// callback to the response
		0;	// user parameter
	0;;

Note :

The function INETGetURLex shound not be used in a new application ! Use this function instead !