User Tools

Site Tools


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
integration_with_other_systems [2019/09/03 15:08]
emozolyak
integration_with_other_systems [2020/05/22 11:37] (current)
emozolyak [Implementing other requests like PUT]
Line 54: Line 54:
 </​code>​ </​code>​
  
 +===== Implementing other requests like PUT =====
 +
 +To implement other requests, you can use special field in the cURL for the custom methods:
 +
 +<code lua>
 +function main (userId)
 + 
 +    INFO("​Doing CURL"​);​
 + 
 +  str = '' ​
 +  ​
 +  c = cURL.easy_init()
 +  c:​setopt_url("​http://​192.168.1.230:​8000"​)
 +  c:​setopt_timeout(15)
 +  c:​setopt{[cURL.OPT_CUSTOMREQUEST] = "​PUT"​} ​ -- this is custom method
 +  ​
 +  c:setopt{
 +        [cURL.OPT_POSTFIELDS] = '​Content-type:​ text/​html'​
 +  }
 +  c:​post({'​THIS IS CONTENT OF THE PUT'})
 +  c:​perform({writefunction = function(res) str = res end })
 +  c:close()
 +
 +  INFO("​CURL done\n"​ .. str);
 +end
 +</​code>​
 ===== Example - connecting to a remote module via its web server ===== ===== Example - connecting to a remote module via its web server =====
  

Page Tools