diff options
| author | Diego Nehab <diego@tecgraf.puc-rio.br> | 2004-10-11 06:18:57 +0000 |
|---|---|---|
| committer | Diego Nehab <diego@tecgraf.puc-rio.br> | 2004-10-11 06:18:57 +0000 |
| commit | 1e5e8b5ce5573fddc7060dae3c1bf2c02788b35a (patch) | |
| tree | 35012ac4464bf4a3c8ed942495ef37319b6c9ad1 | |
| parent | a04f15d1ca440006a53bd0d9f98c12e5abebd969 (diff) | |
| download | luasocket-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-- | FIX | 2 | ||||
| -rw-r--r-- | TODO | 5 | ||||
| -rw-r--r-- | etc/check-links.lua | 4 | ||||
| -rw-r--r-- | etc/check-memory.lua | 10 | ||||
| -rw-r--r-- | etc/dict.lua | 6 | ||||
| -rw-r--r-- | etc/get.lua | 6 | ||||
| -rw-r--r-- | etc/lp.lua | 1 | ||||
| -rw-r--r-- | etc/tftp.lua | 4 | ||||
| -rw-r--r-- | samples/cddb.lua | 2 | ||||
| -rw-r--r-- | samples/lpr.lua | 2 | ||||
| -rw-r--r-- | src/http.lua | 17 | ||||
| -rw-r--r-- | src/luasocket.c | 2 | ||||
| -rw-r--r-- | src/mime.c | 2 | ||||
| -rw-r--r-- | test/dicttest.lua | 3 | ||||
| -rw-r--r-- | test/tftptest.lua | 2 | ||||
| -rw-r--r-- | test/urltest.lua | 2 |
16 files changed, 46 insertions, 24 deletions
| @@ -1,2 +1,4 @@ | |||
| 1 | gettime returns time since Unix Epoch 1/1/1970 (UTC) | 1 | gettime returns time since Unix Epoch 1/1/1970 (UTC) |
| 2 | sleep is robust to interrupts | 2 | sleep is robust to interrupts |
| 3 | select had a stupid bug | ||
| 4 | http.PROXY etc wasn't working | ||
| @@ -1,6 +1,5 @@ | |||
| 1 | ftp.send/recv return bytes transfered? | ||
| 1 | new scheme to choose family/protocol of object to create | 2 | new scheme to choose family/protocol of object to create |
| 2 | use new distribution scheme | ||
| 3 | fix PROXY in http.lua | ||
| 4 | change ltn13 to make sure drawbacks are obvious | 3 | change ltn13 to make sure drawbacks are obvious |
| 5 | - check discussion | 4 | - check discussion |
| 6 | make sure errors not thrown by try() are not caught by protect() | 5 | make 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 | ----------------------------------------------------------------------------- |
| 7 | local http = require("http") | 7 | local http = require("socket.http") |
| 8 | local url = require("url") | 8 | local url = require("socket.url") |
| 9 | http.TIMEOUT = 10 | 9 | http.TIMEOUT = 10 |
| 10 | 10 | ||
| 11 | function readfile(path) | 11 | function 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) | |||
| 8 | end | 8 | end |
| 9 | 9 | ||
| 10 | load("socket") | 10 | load("socket") |
| 11 | load("url") | 11 | load("socket.url") |
| 12 | load("ltn12") | 12 | load("ltn12") |
| 13 | load("mime") | 13 | load("mime") |
| 14 | load("tp") | 14 | load("socket.tp") |
| 15 | load("smtp") | 15 | load("socket.smtp") |
| 16 | load("http") | 16 | load("socket.http") |
| 17 | load("ftp") | 17 | load("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 | ----------------------------------------------------------------------------- |
| 11 | local socket = require("socket") | 11 | local socket = require("socket") |
| 12 | local url = require("url") | 12 | local url = require("socket.url") |
| 13 | local tp = require("tp") | 13 | local tp = require("socket.tp") |
| 14 | |||
| 15 | module("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 | ----------------------------------------------------------------------------- |
| 7 | local socket = require("socket") | 7 | local socket = require("socket") |
| 8 | local http = require("http") | 8 | local http = require("socket.http") |
| 9 | local ftp = require("ftp") | 9 | local ftp = require("socket.ftp") |
| 10 | local url = require("url") | 10 | local url = require("socket.url") |
| 11 | local ltn12 = require("ltn12") | 11 | local 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 |
| @@ -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 |
| 42 | print("'" .. 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 } |
| 45 | end | 44 | end |
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 | ----------------------------------------------------------------------------- |
| 11 | local socket = require("socket") | 11 | local socket = require("socket") |
| 12 | local ltn12 = require("ltn12") | 12 | local ltn12 = require("ltn12") |
| 13 | local url = require("url") | 13 | local url = require("socket.url") |
| 14 | |||
| 15 | module("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 @@ | |||
| 1 | local socket = require("socket") | 1 | local socket = require("socket") |
| 2 | local http = require("http") | 2 | local http = require("socket.http") |
| 3 | 3 | ||
| 4 | if not arg or not arg[1] or not arg[2] then | 4 | if 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 @@ | |||
| 1 | local lp = require("lp") | 1 | local lp = require("socket.lp") |
| 2 | 2 | ||
| 3 | local function usage() | 3 | local 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 | ----------------------------------------------------------------------------- |
| 116 | local function uri(reqt) | 116 | local 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) |
| 127 | end | 128 | end |
| 128 | 129 | ||
| 130 | local 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 | ||
| 138 | end | ||
| 139 | |||
| 129 | local function adjustheaders(headers, host) | 140 | local 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 |
| @@ -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 @@ | |||
| 1 | local dict = require"socket.dict" | ||
| 2 | |||
| 3 | for 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 |
| 2 | local tftp = require("tftp") | 2 | local 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 @@ | |||
| 1 | local socket = require("socket") | 1 | local socket = require("socket") |
| 2 | socket.url = require("url") | 2 | socket.url = require("socket.url") |
| 3 | dofile("testsupport.lua") | 3 | dofile("testsupport.lua") |
| 4 | 4 | ||
| 5 | local check_build_url = function(parsed) | 5 | local check_build_url = function(parsed) |
