Cnanges in HTTP Driver

In iRIdium mobile 3.0 HTTP driver was improved. New functions were added.
Now a packet can be formed on your own.

Sending data to a device
IR.GetDevice("AV & Custom Systems (HTTP)")..SendEx(
Type: "Type of forming a request", The following types are possible GET, POST, PUT.
Url: "Link to the object that is requested",
For POST and PUT requests Data field is also available.
Data: [""],

The next block is Header. it is what your client must send to the requested server.
Headers: {
"Accept": "application/xml;",
"Accept-Language": "de,en-us;q=0.7,en;q=0.3",
"User-Agent" : "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)"
New functions are added. A capability was added to get an answer from the server to any request. Now a definite receive can be added to a definite request. Before it there was only one common receive for the driver.

cbReceiveData - function of processing receive in DATA format with the following parameters:
data - data,
code - answer from the server,
headers - headers.
cbReceiveData: function(data, code, headers) { IR.Log("Data receipt in Data format: \n Code answer from the server: " + code + "\n Data: "+ data); },

cbRecieveText - Processing function from receive TEXT format, with the following parameters:
data - data,
code - answer from the server,
headers - headers.
cbReceiveText: function(text, code, headers) {IR.Log("Data receipt in Text format: \n Code answer from the server: " +code + "\n Data: " + text + "\n Headers: " + headers);},

cbRecieveKey - Header processing function, with the following parameters:
key - header
value - header value.
cbReceiveKey: function(key, value) {IR.Log("Headers: "+ key + "\n Header value: "+ value);},

cbReceiveCode - Function of getting an answer from the server with the following patamaters:
code - answer from the server .
cbReceiveCode: function(code) {IR.Log("Code answer from the server: "+code);},

cbRecieveStartBody - function of starting processing work with the answer from the server
cbReceiveStartBody: function() {},

cbRecievePartBody - "Body" function of processing and receiving the stream.
cbReceivePartBody: function(stream) {IR.Log("Receiving data in ByteStream format (Data object): "+stream);},

cbRecieveEndBody - function of finishing work with the stream
cbReceiveEndBody: function(size) {IR.Log("Size of received stream (Stream): "+size);} ,

cbTimeOut - processing function with time for waiting an answer from the server.
cbTimeOut: function() {IR.Log("cbTimeOut: TimeOut")},

cbRecieveStream - stream processing function.
cbReceiveStream: function(stream, code, headers) { IR.Log("Receiving data in ByteStream format: \n Code answer from the server: " +code + "\n Data object: " + stream); }
You can see how it's realized a driver in the attached project Full test HTTP_v2.irpz

This article was helpful for 6 people. Is this article helpful for you?