Skip to content

Commit 155ab5c

Browse files
author
minggo
committed
Merge pull request #45 from dualface/improved_luasocket_and_quick
improve luasocket and quick C++ support
2 parents d0fcc55 + daa862b commit 155ab5c

17 files changed

+2383
-165
lines changed

lua/luasocket/luasocket_scripts.c

Lines changed: 2195 additions & 0 deletions
Large diffs are not rendered by default.

lua/luasocket/luasocket_scripts.h

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
2+
/* luasocket_scripts.h.h */
3+
4+
#ifndef __LUA_MODULES_7381EB5AEEAEA2DF0F25EF8827143F4A_H_
5+
#define __LUA_MODULES_7381EB5AEEAEA2DF0F25EF8827143F4A_H_
6+
7+
#if __cplusplus
8+
extern "C" {
9+
#endif
10+
11+
#include "lua.h"
12+
13+
void luaopen_luasocket_scripts(lua_State* L);
14+
15+
/*
16+
int luaopen_lua_m_ltn12(lua_State* L);
17+
int luaopen_lua_m_mime(lua_State* L);
18+
int luaopen_lua_m_socket_ftp(lua_State* L);
19+
int luaopen_lua_m_socket_headers(lua_State* L);
20+
int luaopen_lua_m_socket_http(lua_State* L);
21+
int luaopen_lua_m_socket_mbox(lua_State* L);
22+
int luaopen_lua_m_socket_smtp(lua_State* L);
23+
int luaopen_lua_m_socket_tp(lua_State* L);
24+
int luaopen_lua_m_socket_url(lua_State* L);
25+
int luaopen_lua_m_socket(lua_State* L);
26+
*/
27+
28+
#if __cplusplus
29+
}
30+
#endif
31+
32+
#endif /* __LUA_MODULES_7381EB5AEEAEA2DF0F25EF8827143F4A_H_ */
File renamed without changes.
File renamed without changes.
File renamed without changes.

lua/luasocket/ftp.lua renamed to lua/luasocket/script/socket/ftp.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ local base = _G
1111
local table = require("table")
1212
local string = require("string")
1313
local math = require("math")
14-
local socket = require("socket")
14+
local socket = require("socket.socket")
1515
local url = require("socket.url")
1616
local tp = require("socket.tp")
1717
local ltn12 = require("ltn12")
@@ -282,4 +282,4 @@ _M.get = socket.protect(function(gett)
282282
else return tget(gett) end
283283
end)
284284

285-
return _M
285+
return _M

lua/luasocket/headers.lua renamed to lua/luasocket/script/socket/headers.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
-- LuaSocket toolkit.
44
-- Author: Diego Nehab
55
-----------------------------------------------------------------------------
6-
local socket = require("socket")
6+
local socket = require("socket.socket")
77
socket.headers = {}
88
local _M = socket.headers
99

@@ -101,4 +101,4 @@ _M.canonic = {
101101
["x-mailer"] = "X-Mailer",
102102
}
103103

104-
return _M
104+
return _M

lua/luasocket/http.lua renamed to lua/luasocket/script/socket/http.lua

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
-----------------------------------------------------------------------------
88
-- Declare module and import dependencies
99
-------------------------------------------------------------------------------
10-
local socket = require("socket")
10+
local socket = require("socket.socket")
1111
local url = require("socket.url")
12-
local ltn12 = require("ltn12")
13-
local mime = require("mime")
12+
local ltn12 = require("socket.ltn12")
13+
local mime = require("socket.mime")
1414
local string = require("string")
1515
local headers = require("socket.headers")
1616
local base = _G
@@ -217,7 +217,7 @@ local function adjustheaders(reqt)
217217
}
218218
-- if we have authentication information, pass it along
219219
if reqt.user and reqt.password then
220-
lower["authorization"] =
220+
lower["authorization"] =
221221
"Basic " .. (mime.b64(reqt.user .. ":" .. reqt.password))
222222
end
223223
-- override with user headers
@@ -241,7 +241,7 @@ local function adjustrequest(reqt)
241241
-- explicit components override url
242242
for i,v in base.pairs(reqt) do nreqt[i] = v end
243243
if nreqt.port == "" then nreqt.port = 80 end
244-
socket.try(nreqt.host and nreqt.host ~= "",
244+
socket.try(nreqt.host and nreqt.host ~= "",
245245
"invalid host '" .. base.tostring(nreqt.host) .. "'")
246246
-- compute uri if user hasn't overriden
247247
nreqt.uri = reqt.uri or adjusturi(nreqt)
@@ -279,10 +279,10 @@ local trequest, tredirect
279279
source = reqt.source,
280280
sink = reqt.sink,
281281
headers = reqt.headers,
282-
proxy = reqt.proxy,
282+
proxy = reqt.proxy,
283283
nredirects = (reqt.nredirects or 0) + 1,
284284
create = reqt.create
285-
}
285+
}
286286
-- pass location header back as a hint we redirected
287287
headers = headers or {}
288288
headers.location = headers.location or location
@@ -299,7 +299,7 @@ end
299299
h:sendheaders(nreqt.headers)
300300
-- if there is a body, send it
301301
if nreqt.source then
302-
h:sendbody(nreqt.headers, nreqt.source, nreqt.step)
302+
h:sendbody(nreqt.headers, nreqt.source, nreqt.step)
303303
end
304304
local code, status = h:receivestatusline()
305305
-- if it is an HTTP/0.9 server, simply get the body and we are done
@@ -309,13 +309,13 @@ end
309309
end
310310
local headers
311311
-- ignore any 100-continue messages
312-
while code == 100 do
312+
while code == 100 do
313313
headers = h:receiveheaders()
314314
code, status = h:receivestatusline()
315315
end
316316
headers = h:receiveheaders()
317317
-- at this point we should have a honest reply from the server
318-
-- we can't redirect if we already used the source, so we report the error
318+
-- we can't redirect if we already used the source, so we report the error
319319
if shouldredirect(nreqt, code, headers) and not nreqt.source then
320320
h:close()
321321
return tredirect(reqt, headers.location)
@@ -351,4 +351,4 @@ _M.request = socket.protect(function(reqt, body)
351351
else return trequest(reqt) end
352352
end)
353353

354-
return _M
354+
return _M
File renamed without changes.

lua/luasocket/smtp.lua renamed to lua/luasocket/script/socket/smtp.lua

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ local coroutine = require("coroutine")
1212
local string = require("string")
1313
local math = require("math")
1414
local os = require("os")
15-
local socket = require("socket")
15+
local socket = require("socket.socket")
1616
local tp = require("socket.tp")
17-
local ltn12 = require("ltn12")
17+
local ltn12 = require("socket.ltn12")
1818
local headers = require("socket.headers")
19-
local mime = require("mime")
19+
local mime = require("socket.mime")
2020

2121
socket.smtp = {}
2222
local _M = socket.smtp
@@ -253,4 +253,4 @@ _M.send = socket.protect(function(mailt)
253253
return s:close()
254254
end)
255255

256-
return _M
256+
return _M

0 commit comments

Comments
 (0)