LuaSocket can't do HTTPS and instead just silently shunts you to HTTP, which will not work on the modern secure web.
You will have to also wrap your connection with LuaSec.
Quote:
$ curl -v http://dl.dropboxusercontent.com/u/2138237/version.txt
* About to connect() to dl.dropboxusercontent.com port 80 (#0)
* Trying 107.21.220.74...
* Connected to dl.dropboxusercontent.com (107.21.220.74) port 80 (#0)
> GET /u/2138237/version.txt HTTP/1.1
> User-Agent: curl/7.29.0
> Host: dl.dropboxusercontent.com
> Accept: */*
>
< HTTP/1.1 302 FOUND
< cache-control: no-cache
< Content-Type: text/html; charset=utf-8
< Date: Thu, 24 Jul 2014 16:33:48 GMT
< location: https://dl.dropboxusercontent.com/u/2138237/version.txt
< pragma: no-cache
< Server: nginx
< set-cookie: flash=; Domain=dropbox.com; expires=Thu, 24 Jul 2014 16:33:48 GMT; Path=/; httponly
< set-cookie: bang=; Domain=dropbox.com; expires=Thu, 24 Jul 2014 16:33:48 GMT; Path=/; httponly
< set-cookie: uc_session=HKU7emqrjWnamp53RyvEQGYzOQrcBOtViaO9MbI7dVs94MBQO2l8dpoKFMfHCfa1; Domain=dropboxusercontent.com; Path=/; secure; httponly
< Content-Length: 374
< Connection: keep-alive
<
<html>
<head><title>Found</title></head>
<body>
<h1>Found</h1>
<p>The resource was found at <a href="https://dl.dropboxusercontent.com/u/2138237/version.txt">https://dl.dropboxusercontent.com/u/2138237/version.txt</a>;
you should be redirected automatically.
<!-- --></p>
<hr noshade>
<div align="right">WSGI Server</div>
</body>
</html>
* Connection #0 to host dl.dropboxusercontent.com left intact
I ran into the same thing when I started using github, which also does not allow HTTP connections.
I now have a wrapper for doing asynchronous HTTPS using LuaSec, LuaSocket, and lua-llthreads.
Relevant files in my repo are (I think this is all of them):
https://github.com/fiendish/aardwolfclientpackage/blob/MUSHclient/MUSHclient/lua/async.lua
https://github.com/fiendish/aardwolfclientpackage/blob/MUSHclient/MUSHclient/lua/ssl/https.lua
https://github.com/fiendish/aardwolfclientpackage/blob/MUSHclient/MUSHclient/lua/ssl.lua
https://github.com/fiendish/aardwolfclientpackage/blob/development/MUSHclient/llthreads.dll
[EDIT] I've since switched from LuaSec to Lua-openssl because luasec was not thread-safe and the lua-openssl creator actually pays attention to pull requests and comments.
https://github.com/zhaozg/lua-openssl
The
complete set of files related to sockets, ssl, and threading should be:
MUSHclient/socket/*
MUSHclient/lua/ssl/*
MUSHclient/mime/*
MUSHclient/lua/async.lua (for asynchronous background sockets)
MUSHclient/lua/ssl.lua
MUSHclient/lua/socket.lua
MUSHclient/libeay32.dll
MUSHclient/llthreads.dll (for asynchronous background sockets)
MUSHclient/openssl.dll
MUSHclient/ssleay32.dll
You might also need to replace your lua dll with mine (there are two), since I use LuaJIT instead of PUC-Rio Lua, and then also include the msvcr100 dll if you don't have it in your system32 directory.
As Nick mentions below, Dependency Walker is a great tool for determining what's still missing.
Then...
async_ok, async = pcall (require, "async")
thread = nil
Then somewhere where you want to initiate the background request...
if async_ok and not thread then
thread = async.request(version_url, "HTTPS")
end
Then at some later point when you expect the request to be complete...
retval, page, status, headers, full_status = thread:join()
thread = nil
if status == 200 then -- 200 is the HTTP status code for "OK"
-- parse page
else
-- access error
end
The async stuff isn't necessary, it just prevents long pauses on slow server response ( you can test with http://fake-response.appspot.com/?sleep=5 ) because the version of LuaSec I'm using didn't seem to support it natively.