luasocket

https request in lua

Deadly 提交于 2019-12-02 23:22:25
I am trying to retrieve a page on my SSL enabled server with a lua script. Important to note that the server has a self-signed certificate. No problem with certificate issued by a trusted CA. local https = require("socket.http") local resp = {} local r, c, h, s = https.request{ url = "https://my-server:443/example.php", sink = ltn12.sink.table(resp), protocol = "tlsv1" } The server returns: Bad Request Your browser sent a request that this server could not understand. Reason: You're speaking plain HTTP to an SSL-enabled server port. Instead use the HTTPS scheme to access this URL, please. And

Luasocket custom headers, 404 turns to 301

可紊 提交于 2019-12-02 06:18:21
问题 My previous question was about fetching page title in lua using the socket.http module. The question lies here. Previously, youtube pages led me to a 404 error page . Based on MattJ's help, I put up custom HOST header for the request. This is what I did and what was the result: Code header = { host= "youtube.com" } local result,b,c,h = http.request{ url = "http://www.youtube.com/watch?v=_eT40eV7OiI", headers = header } print ( result, b, c, h ) for k,v in pairs(c) do print(k,v) end Result 1

LuaSocket (UDP) not receiving datagrams

跟風遠走 提交于 2019-12-02 05:25:00
问题 I'm experimenting with LuaSocket for a project I'm working on. I've chosen UDP as my protocol. Looking for docs and tutorials online, I've attempted to create a client-server pair for testing and learning. According to what I've read, the following code should work. However, only the server seems to be working properly. The client sends a message, but it will not receive the reply from the server. Thank you for any help anyone can provide. Server: -- Server #!/usr/bin/env lua5.1 local socket

Lua https timeout is not working

十年热恋 提交于 2019-12-02 05:11:35
I am using following versions of Lua and it's packets on openWRT environment: luasocket-2.0.2 luasec-0.4 lua-5.1.4 Trying to use timeout for a https.request call. Tried using https.TIMEOUT where local https = require("ssl.https") and it never time outs. I tried giving a very small timeout (I know that I won't get answer in that time and internet connection is OK) also I tried when net connection is disconnected once https.request is called. Is it a known issue? or shall I try something else for this. I can guess either send/recieve is blocking it for infinite time. -Swapnel Setting the timeout

Lua 5.2 adding luasocket (unstable)

笑着哭i 提交于 2019-12-02 04:41:12
问题 Im trying to use luasocket with lua 5.2. i downloaded the code form the git repository and built it. then made a make install so that it generated core.dll and mime.dll. put those into the custom lua program directory [CPATH] im developing and tried loading it. But i get following error message: Failed at error loading module 'socket.core' from file 'D:\[..myprogram..]\socket\core.dll': Module was not found. how can i check if the dll is correct. or did i do anything wrong? Thanks 回答1: Is

LuaSocket (UDP) not receiving datagrams

孤街醉人 提交于 2019-12-02 01:40:54
I'm experimenting with LuaSocket for a project I'm working on. I've chosen UDP as my protocol. Looking for docs and tutorials online, I've attempted to create a client-server pair for testing and learning. According to what I've read, the following code should work. However, only the server seems to be working properly. The client sends a message, but it will not receive the reply from the server. Thank you for any help anyone can provide. Server: -- Server #!/usr/bin/env lua5.1 local socket = require("socket") udp = socket.udp() udp:setsockname("*", 53474) udp:settimeout(0) while true do data

Lua 5.2 adding luasocket (unstable)

一笑奈何 提交于 2019-12-02 00:04:53
Im trying to use luasocket with lua 5.2. i downloaded the code form the git repository and built it. then made a make install so that it generated core.dll and mime.dll. put those into the custom lua program directory [CPATH] im developing and tried loading it. But i get following error message: Failed at error loading module 'socket.core' from file 'D:\[..myprogram..]\socket\core.dll': Module was not found. how can i check if the dll is correct. or did i do anything wrong? Thanks Is your executable residing in the same directory as your lua files? Try putting the dll in the directory of your

Fetching page of url using luasocket and proxy

有些话、适合烂在心里 提交于 2019-12-01 05:54:29
So far, I have the following piece: local socket = require "socket.http" client,r,c,h = socket.request{url = "http://example.com/", proxy="<my proxy and port here>"} for i,v in pairs( c ) do print( i, v ) end which gives me an output like the following: connection close content-type text/html; charset=UTF-8 location http://www.iana.org/domains/example/ vary Accept-Encoding date Tue, 24 Apr 2012 21:43:19 GMT last-modified Wed, 09 Feb 2011 17:13:15 GMT transfer-encoding chunked server Apache/2.2.3 (CentOS) which means that the connection established just perfectly . Now, I want to fetch the

Fetching page of url using luasocket and proxy

橙三吉。 提交于 2019-12-01 03:04:11
问题 So far, I have the following piece: local socket = require "socket.http" client,r,c,h = socket.request{url = "http://example.com/", proxy="<my proxy and port here>"} for i,v in pairs( c ) do print( i, v ) end which gives me an output like the following: connection close content-type text/html; charset=UTF-8 location http://www.iana.org/domains/example/ vary Accept-Encoding date Tue, 24 Apr 2012 21:43:19 GMT last-modified Wed, 09 Feb 2011 17:13:15 GMT transfer-encoding chunked server Apache/2

How to use Lua 5.2 with luasocket 3

一个人想着一个人 提交于 2019-11-29 06:46:12
I am trying to compile luasocket 3 that I found on GitHub with lua 5.2 . Problem is, I'm not sure how to bind together Lua with luasocket . Do I need to compile luasocket as DLL and then reference if somewhere in lua code, or should I just call it from lua console? Try installing it using luarocks . If you don't have luarocks, install it following instructions on the site. Then download the rockspec file(luasocket-scm-0.rockspec) from luasocket repo and run $ luarocks install *path to the rockspec file* If everything goes OK, you'll be able to use luasocket from Lua like this: local socket =