[luci] Curl in LuCI?

Pau hakais at gmail.com
Thu Feb 6 14:20:58 CET 2014


Hi.
I don't know if it can help, sorry if not.

Recently we created the package "lua-curl" for OpenWRT:

http://redmine.confine-project.eu/projects/wibed-packages/repository/revisions/master/show/lua-curl

Maybe you can use it.

PS: I would like to push this packet in some openwrt feed but I don't
know which one. Any idea?
--
./p4u


On Thu, Feb 6, 2014 at 1:28 PM, Helen Fornazier <helen at wizzilab.com> wrote:
> Hi Andrew,
>
> I am really really sorry I didn't answer you.
>
> Thanks a lot
>
> Helen Fornazier
>
>
> On Thu, Jan 9, 2014 at 4:37 PM, Andrew Reynolds
> <andrew at opentechinstitute.org> wrote:
>>
>> On 12/06/2013 11:51 AM, Helen Fornazier wrote:
>> > I see in LuCI many functions to parse http requests, but is there any
>> > function to perform an http GET or POST requests? As a client?
>>
>> Hi Helen,
>>
>> You can perform http GET or POST requests using luci.httpclient (package
>> luci-lib-httpclient). You will need one of the luci-lib-nixio-ssl
>> packages to do https requests.
>>
>> I used the httpclient.request_raw() function, which requires you to
>> define your http headers and message body, including the form
>> parameters, then pass those values to the function.
>>
>> Here's how I did it. Unfortunately I didn't find any httpclient
>> documentation, so this is just what worked for me through trial and error.
>>
>> In this snippet, I am submitting a machine hostname (hostname) and some
>> json data (json_data) to a form on a central server (listener_url).
>>
>> --[[
>> -- import httpclient
>> local https = require "luci.httpclient"
>>
>> -- organize data
>> local hostname="my.host"
>> node_json="{string:value}"
>>
>> -- build request
>> local listener_url="https://my.server/path_to_form"
>> local options={}
>> options.headers = {}
>> options.headers["Connection"] = "keep-alive"
>> options.headers["Content-Type"] = "application/x-www-form-urlencoded"
>> options.sndtimeo = '100'
>> options.rcvtimeo = '50'
>> -- options.method can also use "GET"
>> options.method = "POST"
>> options.message= {}
>> options.body = {}
>> -- structure: options.body.formid = formvalue
>> options.body.host = hostname
>> options.body.json = node_json
>>
>> -- submit request
>> https.request_raw(listener_url, options)
>> ]]--
>>
>> Httpclient seems to have reasonable defaults, so you may not have to put
>> a lot of effort into defining your http headers. The meat of the form is
>> in options.body, where you just append key=value pairs corresponding to
>> the form IDs and values. Don't forget to include any hidden values.
>>
>> Hope this helps!
>>
>> -andrew
>>
>>
>>
>>
>> _______________________________________________
>> luci mailing list
>> luci at lists.subsignal.org
>> https://lists.subsignal.org/mailman/listinfo/luci
>>
>
>
> _______________________________________________
> luci mailing list
> luci at lists.subsignal.org
> https://lists.subsignal.org/mailman/listinfo/luci
>


More information about the luci mailing list