aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDiego Nehab <diego@tecgraf.puc-rio.br>2004-10-11 06:18:57 +0000
committerDiego Nehab <diego@tecgraf.puc-rio.br>2004-10-11 06:18:57 +0000
commit1e5e8b5ce5573fddc7060dae3c1bf2c02788b35a (patch)
tree35012ac4464bf4a3c8ed942495ef37319b6c9ad1
parenta04f15d1ca440006a53bd0d9f98c12e5abebd969 (diff)
downloadluasocket-1e5e8b5ce5573fddc7060dae3c1bf2c02788b35a.tar.gz
luasocket-1e5e8b5ce5573fddc7060dae3c1bf2c02788b35a.tar.bz2
luasocket-1e5e8b5ce5573fddc7060dae3c1bf2c02788b35a.zip
Fine tunned modules scheme.
Adjusted client modules. Fixed proxy bug in http.
-rw-r--r--FIX2
-rw-r--r--TODO5
-rw-r--r--etc/check-links.lua4
-rw-r--r--etc/check-memory.lua10
-rw-r--r--etc/dict.lua6
-rw-r--r--etc/get.lua6
-rw-r--r--etc/lp.lua1
-rw-r--r--etc/tftp.lua4
-rw-r--r--samples/cddb.lua2
-rw-r--r--samples/lpr.lua2
-rw-r--r--src/http.lua17
-rw-r--r--src/luasocket.c2
-rw-r--r--src/mime.c2
-rw-r--r--test/dicttest.lua3
-rw-r--r--test/tftptest.lua2
-rw-r--r--test/urltest.lua2
16 files changed, 46 insertions, 24 deletions
diff --git a/FIX b/FIX
index 15eb4a9..5c31d3c 100644
--- a/FIX
+++ b/FIX
@@ -1,2 +1,4 @@
1gettime returns time since Unix Epoch 1/1/1970 (UTC) 1gettime returns time since Unix Epoch 1/1/1970 (UTC)
2sleep is robust to interrupts 2sleep is robust to interrupts
3select had a stupid bug
4http.PROXY etc wasn't working
diff --git a/TODO b/TODO
index 9023555..1062177 100644
--- a/TODO
+++ b/TODO
@@ -1,6 +1,5 @@
1ftp.send/recv return bytes transfered?
1new scheme to choose family/protocol of object to create 2new scheme to choose family/protocol of object to create
2use new distribution scheme
3fix PROXY in http.lua
4change ltn13 to make sure drawbacks are obvious 3change ltn13 to make sure drawbacks are obvious
5 - check discussion 4 - check discussion
6make sure errors not thrown by try() are not caught by protect() 5make sure errors not thrown by try() are not caught by protect()
@@ -24,6 +23,8 @@ testar os options!
24 - proteger ou atomizar o conjunto (timedout, receive), (timedout, send) 23 - proteger ou atomizar o conjunto (timedout, receive), (timedout, send)
25 - inet_ntoa também é uma merda. 24 - inet_ntoa também é uma merda.
26 25
26*fix PROXY in http.lua
27*use new distribution scheme
27*create the getstats method. 28*create the getstats method.
28*fix local domain socket kludge of name size 29*fix local domain socket kludge of name size
29*use TLS 30*use TLS
diff --git a/etc/check-links.lua b/etc/check-links.lua
index 4487593..79e6a54 100644
--- a/etc/check-links.lua
+++ b/etc/check-links.lua
@@ -4,8 +4,8 @@
4-- Author: Diego Nehab 4-- Author: Diego Nehab
5-- RCS ID: $Id$ 5-- RCS ID: $Id$
6----------------------------------------------------------------------------- 6-----------------------------------------------------------------------------
7local http = require("http") 7local http = require("socket.http")
8local url = require("url") 8local url = require("socket.url")
9http.TIMEOUT = 10 9http.TIMEOUT = 10
10 10
11function readfile(path) 11function readfile(path)
diff --git a/etc/check-memory.lua b/etc/check-memory.lua
index fdc6b9b..7892ba0 100644
--- a/etc/check-memory.lua
+++ b/etc/check-memory.lua
@@ -8,10 +8,10 @@ function load(s)
8end 8end
9 9
10load("socket") 10load("socket")
11load("url") 11load("socket.url")
12load("ltn12") 12load("ltn12")
13load("mime") 13load("mime")
14load("tp") 14load("socket.tp")
15load("smtp") 15load("socket.smtp")
16load("http") 16load("socket.http")
17load("ftp") 17load("socket.ftp")
diff --git a/etc/dict.lua b/etc/dict.lua
index dce1658..8c197f5 100644
--- a/etc/dict.lua
+++ b/etc/dict.lua
@@ -9,8 +9,10 @@
9-- Load required modules 9-- Load required modules
10----------------------------------------------------------------------------- 10-----------------------------------------------------------------------------
11local socket = require("socket") 11local socket = require("socket")
12local url = require("url") 12local url = require("socket.url")
13local tp = require("tp") 13local tp = require("socket.tp")
14
15module("socket.dict")
14 16
15----------------------------------------------------------------------------- 17-----------------------------------------------------------------------------
16-- Globals 18-- Globals
diff --git a/etc/get.lua b/etc/get.lua
index 712d807..0c95d54 100644
--- a/etc/get.lua
+++ b/etc/get.lua
@@ -5,9 +5,9 @@
5-- RCS ID: $Id$ 5-- RCS ID: $Id$
6----------------------------------------------------------------------------- 6-----------------------------------------------------------------------------
7local socket = require("socket") 7local socket = require("socket")
8local http = require("http") 8local http = require("socket.http")
9local ftp = require("ftp") 9local ftp = require("socket.ftp")
10local url = require("url") 10local url = require("socket.url")
11local ltn12 = require("ltn12") 11local ltn12 = require("ltn12")
12 12
13-- formats a number of seconds into human readable form 13-- formats a number of seconds into human readable form
diff --git a/etc/lp.lua b/etc/lp.lua
index 3c36b11..b69cc02 100644
--- a/etc/lp.lua
+++ b/etc/lp.lua
@@ -39,7 +39,6 @@ local function connect(localhost, option)
39 until localport > 731 39 until localport > 731
40 test(skt, err) 40 test(skt, err)
41 else skt = test(socket.tcp()) end 41 else skt = test(socket.tcp()) end
42print("'" .. host .. "'")
43 try(skt:connect(host, port)) 42 try(skt:connect(host, port))
44 return { skt = skt, try = try } 43 return { skt = skt, try = try }
45end 44end
diff --git a/etc/tftp.lua b/etc/tftp.lua
index 70db050..f4af8bc 100644
--- a/etc/tftp.lua
+++ b/etc/tftp.lua
@@ -10,7 +10,9 @@
10----------------------------------------------------------------------------- 10-----------------------------------------------------------------------------
11local socket = require("socket") 11local socket = require("socket")
12local ltn12 = require("ltn12") 12local ltn12 = require("ltn12")
13local url = require("url") 13local url = require("socket.url")
14
15module("socket.tftp")
14 16
15----------------------------------------------------------------------------- 17-----------------------------------------------------------------------------
16-- Program constants 18-- Program constants
diff --git a/samples/cddb.lua b/samples/cddb.lua
index daa5df1..3e48cf6 100644
--- a/samples/cddb.lua
+++ b/samples/cddb.lua
@@ -1,5 +1,5 @@
1local socket = require("socket") 1local socket = require("socket")
2local http = require("http") 2local http = require("socket.http")
3 3
4if not arg or not arg[1] or not arg[2] then 4if not arg or not arg[1] or not arg[2] then
5 print("luasocket cddb.lua <category> <disc-id> [<server>]") 5 print("luasocket cddb.lua <category> <disc-id> [<server>]")
diff --git a/samples/lpr.lua b/samples/lpr.lua
index d743026..caab387 100644
--- a/samples/lpr.lua
+++ b/samples/lpr.lua
@@ -1,4 +1,4 @@
1local lp = require("lp") 1local lp = require("socket.lp")
2 2
3local function usage() 3local function usage()
4 print('\nUsage: lua lptest.lua [filename] [keyword=val...]\n') 4 print('\nUsage: lua lptest.lua [filename] [keyword=val...]\n')
diff --git a/src/http.lua b/src/http.lua
index 8ea4c47..b265650 100644
--- a/src/http.lua
+++ b/src/http.lua
@@ -113,8 +113,9 @@ end
113----------------------------------------------------------------------------- 113-----------------------------------------------------------------------------
114-- High level HTTP API 114-- High level HTTP API
115----------------------------------------------------------------------------- 115-----------------------------------------------------------------------------
116local function uri(reqt) 116local function adjusturi(reqt)
117 local u = reqt 117 local u = reqt
118 -- if there is a proxy, we need the full url. otherwise, just a part.
118 if not reqt.proxy and not PROXY then 119 if not reqt.proxy and not PROXY then
119 u = { 120 u = {
120 path = socket.try(reqt.path, "invalid path 'nil'"), 121 path = socket.try(reqt.path, "invalid path 'nil'"),
@@ -126,6 +127,16 @@ local function uri(reqt)
126 return url.build(u) 127 return url.build(u)
127end 128end
128 129
130local function adjustproxy(reqt)
131 local proxy = reqt.proxy or PROXY
132 if proxy then
133 proxy = url.parse(proxy)
134 return proxy.host, proxy.port or 3128
135 else
136 return reqt.host, reqt.port
137 end
138end
139
129local function adjustheaders(headers, host) 140local function adjustheaders(headers, host)
130 local lower = {} 141 local lower = {}
131 -- override with user values 142 -- override with user values
@@ -152,7 +163,9 @@ local function adjustrequest(reqt)
152 for i,v in reqt do nreqt[i] = reqt[i] end 163 for i,v in reqt do nreqt[i] = reqt[i] end
153 socket.try(nreqt.host, "invalid host '" .. tostring(nreqt.host) .. "'") 164 socket.try(nreqt.host, "invalid host '" .. tostring(nreqt.host) .. "'")
154 -- compute uri if user hasn't overriden 165 -- compute uri if user hasn't overriden
155 nreqt.uri = nreqt.uri or uri(nreqt) 166 nreqt.uri = reqt.uri or adjusturi(nreqt)
167 -- ajust host and port if there is a proxy
168 nreqt.host, nreqt.port = adjustproxy(nreqt)
156 -- adjust headers in request 169 -- adjust headers in request
157 nreqt.headers = adjustheaders(nreqt.headers, nreqt.host) 170 nreqt.headers = adjustheaders(nreqt.headers, nreqt.host)
158 return nreqt 171 return nreqt
diff --git a/src/luasocket.c b/src/luasocket.c
index ebe9f5f..d07b90f 100644
--- a/src/luasocket.c
+++ b/src/luasocket.c
@@ -19,7 +19,7 @@
19\*=========================================================================*/ 19\*=========================================================================*/
20#include <lua.h> 20#include <lua.h>
21#include <lauxlib.h> 21#include <lauxlib.h>
22#include <compat-5.1.h> 22#include "compat-5.1.h"
23 23
24/*=========================================================================*\ 24/*=========================================================================*\
25* LuaSocket includes 25* LuaSocket includes
diff --git a/src/mime.c b/src/mime.c
index 594135f..8bc20d3 100644
--- a/src/mime.c
+++ b/src/mime.c
@@ -8,7 +8,7 @@
8 8
9#include <lua.h> 9#include <lua.h>
10#include <lauxlib.h> 10#include <lauxlib.h>
11#include <compat-5.1.h> 11#include "compat-5.1.h"
12 12
13#include "mime.h" 13#include "mime.h"
14 14
diff --git a/test/dicttest.lua b/test/dicttest.lua
new file mode 100644
index 0000000..fcdd61f
--- /dev/null
+++ b/test/dicttest.lua
@@ -0,0 +1,3 @@
1local dict = require"socket.dict"
2
3for i,v in dict.get("dict://localhost/d:banana") do print(v) end
diff --git a/test/tftptest.lua b/test/tftptest.lua
index f0dbd82..edb6484 100644
--- a/test/tftptest.lua
+++ b/test/tftptest.lua
@@ -1,5 +1,5 @@
1-- load tftpclnt.lua 1-- load tftpclnt.lua
2local tftp = require("tftp") 2local tftp = require("socket.tftp")
3 3
4-- needs tftp server running on localhost, with root pointing to 4-- needs tftp server running on localhost, with root pointing to
5-- a directory with index.html in it 5-- a directory with index.html in it
diff --git a/test/urltest.lua b/test/urltest.lua
index eb15bcf..570b52e 100644
--- a/test/urltest.lua
+++ b/test/urltest.lua
@@ -1,5 +1,5 @@
1local socket = require("socket") 1local socket = require("socket")
2socket.url = require("url") 2socket.url = require("socket.url")
3dofile("testsupport.lua") 3dofile("testsupport.lua")
4 4
5local check_build_url = function(parsed) 5local check_build_url = function(parsed)