mirror of
https://github.com/lunarmodules/luasocket.git
synced 2024-12-26 04:28:20 +01:00
Fine tunned modules scheme.
Adjusted client modules. Fixed proxy bug in http.
This commit is contained in:
parent
a04f15d1ca
commit
1e5e8b5ce5
2
FIX
2
FIX
@ -1,2 +1,4 @@
|
||||
gettime returns time since Unix Epoch 1/1/1970 (UTC)
|
||||
sleep is robust to interrupts
|
||||
select had a stupid bug
|
||||
http.PROXY etc wasn't working
|
||||
|
5
TODO
5
TODO
@ -1,6 +1,5 @@
|
||||
ftp.send/recv return bytes transfered?
|
||||
new scheme to choose family/protocol of object to create
|
||||
use new distribution scheme
|
||||
fix PROXY in http.lua
|
||||
change ltn13 to make sure drawbacks are obvious
|
||||
- check discussion
|
||||
make sure errors not thrown by try() are not caught by protect()
|
||||
@ -24,6 +23,8 @@ testar os options!
|
||||
- proteger ou atomizar o conjunto (timedout, receive), (timedout, send)
|
||||
- inet_ntoa também é uma merda.
|
||||
|
||||
*fix PROXY in http.lua
|
||||
*use new distribution scheme
|
||||
*create the getstats method.
|
||||
*fix local domain socket kludge of name size
|
||||
*use TLS
|
||||
|
@ -4,8 +4,8 @@
|
||||
-- Author: Diego Nehab
|
||||
-- RCS ID: $Id$
|
||||
-----------------------------------------------------------------------------
|
||||
local http = require("http")
|
||||
local url = require("url")
|
||||
local http = require("socket.http")
|
||||
local url = require("socket.url")
|
||||
http.TIMEOUT = 10
|
||||
|
||||
function readfile(path)
|
||||
|
@ -8,10 +8,10 @@ function load(s)
|
||||
end
|
||||
|
||||
load("socket")
|
||||
load("url")
|
||||
load("socket.url")
|
||||
load("ltn12")
|
||||
load("mime")
|
||||
load("tp")
|
||||
load("smtp")
|
||||
load("http")
|
||||
load("ftp")
|
||||
load("socket.tp")
|
||||
load("socket.smtp")
|
||||
load("socket.http")
|
||||
load("socket.ftp")
|
||||
|
@ -9,8 +9,10 @@
|
||||
-- Load required modules
|
||||
-----------------------------------------------------------------------------
|
||||
local socket = require("socket")
|
||||
local url = require("url")
|
||||
local tp = require("tp")
|
||||
local url = require("socket.url")
|
||||
local tp = require("socket.tp")
|
||||
|
||||
module("socket.dict")
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
-- Globals
|
||||
|
@ -5,9 +5,9 @@
|
||||
-- RCS ID: $Id$
|
||||
-----------------------------------------------------------------------------
|
||||
local socket = require("socket")
|
||||
local http = require("http")
|
||||
local ftp = require("ftp")
|
||||
local url = require("url")
|
||||
local http = require("socket.http")
|
||||
local ftp = require("socket.ftp")
|
||||
local url = require("socket.url")
|
||||
local ltn12 = require("ltn12")
|
||||
|
||||
-- formats a number of seconds into human readable form
|
||||
|
@ -39,7 +39,6 @@ local function connect(localhost, option)
|
||||
until localport > 731
|
||||
test(skt, err)
|
||||
else skt = test(socket.tcp()) end
|
||||
print("'" .. host .. "'")
|
||||
try(skt:connect(host, port))
|
||||
return { skt = skt, try = try }
|
||||
end
|
||||
|
@ -10,7 +10,9 @@
|
||||
-----------------------------------------------------------------------------
|
||||
local socket = require("socket")
|
||||
local ltn12 = require("ltn12")
|
||||
local url = require("url")
|
||||
local url = require("socket.url")
|
||||
|
||||
module("socket.tftp")
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
-- Program constants
|
||||
|
@ -1,5 +1,5 @@
|
||||
local socket = require("socket")
|
||||
local http = require("http")
|
||||
local http = require("socket.http")
|
||||
|
||||
if not arg or not arg[1] or not arg[2] then
|
||||
print("luasocket cddb.lua <category> <disc-id> [<server>]")
|
||||
|
@ -1,4 +1,4 @@
|
||||
local lp = require("lp")
|
||||
local lp = require("socket.lp")
|
||||
|
||||
local function usage()
|
||||
print('\nUsage: lua lptest.lua [filename] [keyword=val...]\n')
|
||||
|
17
src/http.lua
17
src/http.lua
@ -113,8 +113,9 @@ end
|
||||
-----------------------------------------------------------------------------
|
||||
-- High level HTTP API
|
||||
-----------------------------------------------------------------------------
|
||||
local function uri(reqt)
|
||||
local function adjusturi(reqt)
|
||||
local u = reqt
|
||||
-- if there is a proxy, we need the full url. otherwise, just a part.
|
||||
if not reqt.proxy and not PROXY then
|
||||
u = {
|
||||
path = socket.try(reqt.path, "invalid path 'nil'"),
|
||||
@ -126,6 +127,16 @@ local function uri(reqt)
|
||||
return url.build(u)
|
||||
end
|
||||
|
||||
local function adjustproxy(reqt)
|
||||
local proxy = reqt.proxy or PROXY
|
||||
if proxy then
|
||||
proxy = url.parse(proxy)
|
||||
return proxy.host, proxy.port or 3128
|
||||
else
|
||||
return reqt.host, reqt.port
|
||||
end
|
||||
end
|
||||
|
||||
local function adjustheaders(headers, host)
|
||||
local lower = {}
|
||||
-- override with user values
|
||||
@ -152,7 +163,9 @@ local function adjustrequest(reqt)
|
||||
for i,v in reqt do nreqt[i] = reqt[i] end
|
||||
socket.try(nreqt.host, "invalid host '" .. tostring(nreqt.host) .. "'")
|
||||
-- compute uri if user hasn't overriden
|
||||
nreqt.uri = nreqt.uri or uri(nreqt)
|
||||
nreqt.uri = reqt.uri or adjusturi(nreqt)
|
||||
-- ajust host and port if there is a proxy
|
||||
nreqt.host, nreqt.port = adjustproxy(nreqt)
|
||||
-- adjust headers in request
|
||||
nreqt.headers = adjustheaders(nreqt.headers, nreqt.host)
|
||||
return nreqt
|
||||
|
@ -19,7 +19,7 @@
|
||||
\*=========================================================================*/
|
||||
#include <lua.h>
|
||||
#include <lauxlib.h>
|
||||
#include <compat-5.1.h>
|
||||
#include "compat-5.1.h"
|
||||
|
||||
/*=========================================================================*\
|
||||
* LuaSocket includes
|
||||
|
@ -8,7 +8,7 @@
|
||||
|
||||
#include <lua.h>
|
||||
#include <lauxlib.h>
|
||||
#include <compat-5.1.h>
|
||||
#include "compat-5.1.h"
|
||||
|
||||
#include "mime.h"
|
||||
|
||||
|
3
test/dicttest.lua
Normal file
3
test/dicttest.lua
Normal file
@ -0,0 +1,3 @@
|
||||
local dict = require"socket.dict"
|
||||
|
||||
for i,v in dict.get("dict://localhost/d:banana") do print(v) end
|
@ -1,5 +1,5 @@
|
||||
-- load tftpclnt.lua
|
||||
local tftp = require("tftp")
|
||||
local tftp = require("socket.tftp")
|
||||
|
||||
-- needs tftp server running on localhost, with root pointing to
|
||||
-- a directory with index.html in it
|
||||
|
@ -1,5 +1,5 @@
|
||||
local socket = require("socket")
|
||||
socket.url = require("url")
|
||||
socket.url = require("socket.url")
|
||||
dofile("testsupport.lua")
|
||||
|
||||
local check_build_url = function(parsed)
|
||||
|
Loading…
Reference in New Issue
Block a user