Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Last revision Both sides next revision
component:internet [2015/01/14 23:40]
127.0.0.1 external edit
component:internet [2016/07/09 03:49]
gamax92 Add HTTP headers documentation
Line 6: Line 6:
 Callbacks: Callbacks:
  
-- `close(handle:​number)`  ​ 
-  Closes an open socket stream. 
-- `connect(address:​string[,​ port:​number]):​number`  ​ 
-  Opens a new TCP connection. Returns the handle of the connection. 
-- `read(handle:​number[,​ n:​number]):​string`  ​ 
-  Tries to read data from the socket stream. Returns the read byte array. 
 - `isTcpEnabled():​boolean`  ​ - `isTcpEnabled():​boolean`  ​
   Returns whether TCP connections can be made (config setting).   Returns whether TCP connections can be made (config setting).
-- `write(handle:​number,​ data:​string):​number`  ​ 
-  Tries to write data to the socket stream. Returns the number of bytes written. 
-- `finishConnect(handle:​number):​boolean`  ​ 
-  Ensures a socket is connected. Errors if the connection failed. 
 - `isHttpEnabled():​boolean`  ​ - `isHttpEnabled():​boolean`  ​
   Returns whether HTTP requests can be made (config setting).   Returns whether HTTP requests can be made (config setting).
-- `request(url:​string[,​ postData:​string]):​boolean`   +- `connect(address:​string[,​ port:​number]):​userdata` ​  
-  ​Starts an HTTP request. ​If this returns truefurther results will be pushed using `http_responsesignals.+  Opens a new TCP connection. Returns the handle of the connection. 
 +- `request(url:​string[,​ postData:​string[, headers:​table]]):userdata`   
 +  ​Sends a new HTTP request. ​Returns the handle of the connection. 
 + 
 +==== TCP Socket Object ==== 
 + 
 +- `read([n:​number]):​string` ​  
 +  Tries to read data from the socket stream. Returns the read byte array. 
 +- `close()` ​  
 +  Closes an open socket stream. 
 +- `write(data:​string):​number` ​  
 +  Tries to write data to the socket stream. Returns the number of bytes written. 
 +- `finishConnect():​boolean` ​  
 +  Ensures a socket is connected. Errors if the connection failed. 
 + 
 +==== HTTP Request Object ==== 
 + 
 +- `read([n:​number]):​string` ​  
 +  Tries to read data from the response. Returns the read byte array. 
 +- `response():​numberstring, table  
 +  Get response code, message and headers. 
 +`close()` ​  
 +  Closes an open socket stream. 
 +- `finishConnect():​boolean` ​  
 +  Ensures a response is available. Errors if the connection failed.
  
 ---- ----
  
 {{page>​component:​contents&​noheader&​noeditbutton&​nouser&​nofooter}} {{page>​component:​contents&​noheader&​noeditbutton&​nouser&​nofooter}}