Working on the manual.

This commit is contained in:
Diego Nehab 2005-06-14 04:29:23 +00:00
parent 8b114f3bf4
commit 65c35845c5
19 changed files with 91 additions and 91 deletions

15
FIX
View File

@ -1,13 +1,16 @@
url.absolute was not working when base_url was already parsed
http.request was redirecting even when the location header is empty
http.request was redirecting even when the location header was empty
tcp{client}:shutdown() was checking for group instead of class.
tcp{client}:send() now returns i+sent-1...
get rid of a = socket.try() in the manual, except for protected cases.
replace it with assert.
get rid of "base." kludge
get rid of a = socket.try() in the manual, except for protected cases. replace it with assert.
get rid of "base." kludge in package.loaded
check all "require("http")" etc in the manual.
make sure sock_gethostname.* only return success if the hp is not null!
change 'l' prefix in C libraries to 'c'
change 'l' prefix in C libraries to 'c' to avoid clash with LHF libraries
don't forget the declarations in luasocket.h and mime.h!!!
setpeername was using udp{unconnected}
fixed a bug in http.lua that caused some requests to fail
fixed a bug in http.lua that caused some requests to fail (Florian Berger)
fixed a bug in select.c that prevented sockets with descriptor 0 from working (Renato Maia)
fixed a "bug" that caused dns.toip to crash under uLinux
fixed a "bug" that caused a crash in gethostbyname under VMS
DEBUG and VERSION became _DEBUG and _VERSION

3
TODO
View File

@ -1,4 +1,3 @@
talk about the non-blocking connect in the manual
test it on Windows!!!
@ -13,7 +12,6 @@ functions for non-blocking so they can be used in the context of the
dispatcher!
adjust manual for new sock:send returns.
_VERSION, _DEBUG, etc.
leave code for losers that don't have nanosleep
@ -42,3 +40,4 @@ testar os options!
eliminate globals from namespaces created by module().
* BUG NO SET DO TINYIRC!!! SINISTRO.
* _VERSION, _DEBUG, etc.

View File

@ -93,38 +93,24 @@ Windows XP, Linux, and Mac OS X.
</p>
<p>
The library can be downloaded in source code from the following links:
</p>
<blockquote>
<p>
<a href="luasocket-2.0.tar.gz">luasocket-2.0.tar.gz</a> <br>
<a href="luasocket-2.0.zip">luasocket-2.0.zip</a>
</p>
</blockquote>
<p>
The library can be downloaded in source code from the
<a href=http://luaforge.net/projects/luasocket/>LuaSocket
project page</a> at LuaForge.
Besides the full C and Lua source code for the library, the distribution
contains several examples, this user's manual and basic test procedures.
</p>
<p>
I am also providing PC Win32 binaries for those that want to give
LuaSocket a try (those on Unix or Mac OS X can just type <tt>make</tt>).
These are compatible with the
Danilo Tuler is mantaining Win32 binaries for LuaSocket, which are also
available from LuaForge. These are compatible with the
<a href=http://luaforge.net/projects/luabinaries>LuaBinaries</a>
available from LuaForge.
</p>
<blockquote>
<p>
<a href="luasocket-2.0-win32.zip">luasocket-2.0-win32.zip</a>
</p>
</blockquote>
<p>
The quick and dirty way to use these binaries is to unpack everything into
a directory, say <tt>c:\luasocket</tt>, then set <tt>LUA_INIT</tt> to load
For those that want to give LuaSocket a quick try, download the
stand-alone archive and unpack everything into
a directory, say <tt>c:\luasocket</tt>. Then set <tt>LUA_INIT</tt> to load
the <tt>compat-5.1.lua</tt> and set <tt>LUA_PATH</tt> and
<tt>LUA_CPATH</tt> to look for files in the current directory:
</p>
@ -142,10 +128,10 @@ do the following:
</p>
<pre class=example>
c:\luasocket\&gt; lua
c:\luasocket\&gt; lua50
Lua 5.0.2 Copyright (C) 1994-2004 Tecgraf, PUC-Rio
&gt; http = require"socket.http"
&gt; print(http.request"http://www.tecgraf.puc-rio.br/luasocket/")
&gt; print(http.request"http://www.cs.princeton.edu/~diego/professional/luasocket/")
--&gt; the source to this web page gets dumped to terminal
</pre>
@ -173,31 +159,39 @@ has been helping a lot too! Thanks to you all!
<h2 id=new>What's New</h2>
<p>
The big change for the 2.0 (beta3) release was the adoption of the Lua 5.1
package proposal. Naturally, there were a few bug fixes (a beta is a
beta, is a beta).
There is no big change for the 2.0 (final) release. It is basically a
bug fix release. The only improvement is in the non-blocking
support.
</p>
<ul>
<li> New compat-5.1 distribution:
<ul>
<li> Installation uses new directory structure;
<li> Namespace hierarchy is in now back in use (ex. <tt>socket.url</tt>
instead of <tt>url</tt>);
<li> All modules call <tt>require</tt> even for standard libraries;
</ul>
<li> <tt>socket.select</tt> wasn't calling <tt>tm_markstart</tt>;
<li> LTN12 avoids coroutines (so you can go wild on the C side);
<li> Kludge on wsocket.c:sock_send for windows timeout issue
moved to buffer.c:sendraw so it's not a kludge anymore;
<li> <tt>socket.protect </tt>only catches errors thrown by <tt>socket.try</tt>;
<li> Fixed <tt>udp:sendto</tt> to call <tt>sock_sendto</tt> instead of
<tt>sock_send</tt>;
<li> <tt>close</tt> wasn't returning 1!
<li> <tt>socket.gettime</tt> returns time since Unix Epoch 1/1/1970 (UTC);
<li> <tt>socket.sleep</tt> is robust to interrupts;
<li> <tt>http.PROXY</tt> wasn't working;
<li> <tt>url.escape</tt> escapes only dangerous characters.
<li> Improved: <tt>tcp{client}:send(data, i)</tt> now returns <tt>(i+sent-1)</tt>. This is great for non-blocking I/O, but might break some code;
<li> Improved: HTTP, SMTP, and FTP functions accept a new field
<tt>connect</tt> that can be used to replace the function invoked to
create and connect the sockets used internally;
<li> Fixed: <tt>url.absolute()</tt> was not working when <tt>base_url</tt> was
already parsed;
<li> Fixed: <tt>http.request()</tt> was redirecting even when the location
header was empty (well, it shouldn't be empty);
<li> Fixed: <tt>tcp{client}:shutdown()</tt> was checking for group instead of class;
<li> Fixed: <tt>socket.try()</tt> can't be used in place of <tt>assert()</tt>. The manual and examples don't do it anymore;
<li> Improved: Get rid of <tt>require("base")</tt> kludge in <tt>package.loaded</tt>;
<li> Fixedd: Parts of the manual referred to <tt>require("http")</tt> instead of
<tt>require("socket.http")</tt>;
<li> Improved: Changed 'l' prefix in C libraries to 'c' to avoid clash with LHF
libraries;
<li> Improved: Using bundles in Mac OS X;
<li> Fixed: <tt>luasocket.h</tt> was exporting <tt>luaopen_socket</tt>
instead of <tt>luaopen_csocket</tt>;
<li> Fixed: <tt>udp:setpeername()</tt> only worked for
<tt>udp{unconnected}</tt>. Now you can "disconnect" an <tt>UDP</tt> socket;
<li> Fixed: bug in http.lua that caused some requests to fail (Florian
Berger);
<li> Fixed: bug in <tt>select.c</tt> that prevented sockets with descriptor 0 from working (Renato Maia);
<li> Fixed: "bug" that caused <tt>dns.toip</tt> to crash under uLinux;
<li> Fixed: "bug" that caused a crash in <tt>gethostbyname</tt> under VMS
(Renato Maia);
<li> Improved: <tt>socket.DEBUG</tt> and <tt>socket.VERSION</tt> became <tt>socket._DEBUGs</tt> and <tt>socket._VERSION</tt> for uniformity with other libraries.
</ul>
<!-- incompatible +++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
@ -205,9 +199,11 @@ beta, is a beta).
<h3 id=incompatible>Incompatibilities with previous versions</h3>
<ul>
<li> Namespaces are hierarchical again. This means that whoever used to
call <tt>require("url")</tt> should update their code to
<tt>require("socket.url")</tt>.
<li> If you use the return value of <tt>tcp:send()</tt> <em>and</em> you
use the extra parameters to select only part of the string to be sent, your
code is now broken, but when you fix it, it will be much simpler;
<li> If you check <tt>socket.DEBUG</tt> or <tt>socket.VERSION</tt>,
change it to <tt>socket._DEBUG</tt> or <tt>socket._VERSION</tt>.
</ul>
<!-- old ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

View File

@ -142,7 +142,7 @@ Support, Manual">
<blockquote>
<a href="socket.html">Socket</a>
<blockquote>
<a href="socket.html#debug">DEBUG</a>,
<a href="socket.html#_debug">_DEBUG</a>,
<a href="dns.html#dns">dns</a>,
<a href="socket.html#gettime">gettime</a>,
<a href="socket.html#newtry">newtry</a>,
@ -155,7 +155,7 @@ Support, Manual">
<a href="tcp.html#tcp">tcp</a>,
<a href="socket.html#try">try</a>,
<a href="udp.html#udp">udp</a>,
<a href="socket.html#version">VERSION</a>.
<a href="socket.html#_version">_VERSION</a>.
</blockquote>
</blockquote>

View File

@ -85,8 +85,8 @@ the user can also specify the local address and port to bind
<!-- debug ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<p class=name id=debug>
socket.<b>DEBUG</b>
<p class=name id=_debug>
socket.<b>_DEBUG</b>
</p>
<p class=description>
@ -372,8 +372,8 @@ c = socket.try(socket.connect("localhost", 80))
<!-- version ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<p class=name id=version>
socket.<b>VERSION</b>
<p class=name id=_version>
socket.<b>_VERSION</b>
</p>
<p class=description>

View File

@ -8,7 +8,7 @@
-----------------------------------------------------------------------------
-- Load required modules
-----------------------------------------------------------------------------
local base = require("base")
local base = _G
local string = require("string")
local table = require("table")
local socket = require("socket")

View File

@ -10,7 +10,7 @@
]]
-- make sure LuaSocket is loaded
local io = require("io")
local base = require("base")
local base = _G
local string = require("string")
local socket = require("socket")
local ltn12 = require("ltn12")

View File

@ -8,7 +8,7 @@
-----------------------------------------------------------------------------
-- Load required files
-----------------------------------------------------------------------------
local base = require("base")
local base = _G
local table = require("table")
local math = require("math")
local string = require("string")

View File

@ -8,7 +8,7 @@
-----------------------------------------------------------------------------
-- Declare module and import dependencies
-----------------------------------------------------------------------------
local base = require("base")
local base = _G
local table = require("table")
local string = require("string")
local math = require("math")

View File

@ -13,7 +13,7 @@ local url = require("socket.url")
local ltn12 = require("ltn12")
local mime = require("mime")
local string = require("string")
local base = require("base")
local base = _G
local table = require("table")
module("socket.http")
@ -25,7 +25,7 @@ TIMEOUT = 60
-- default port for document retrieval
PORT = 80
-- user agent field sent in request
USERAGENT = socket.VERSION
USERAGENT = socket._VERSION
-----------------------------------------------------------------------------
-- Extra sources and sinks

View File

@ -172,22 +172,26 @@ static void inet_pushresolved(lua_State *L, struct hostent *hp)
i = 1;
alias = hp->h_aliases;
lua_newtable(L);
if (alias) {
while (*alias) {
lua_pushnumber(L, i);
lua_pushstring(L, *alias);
lua_settable(L, -3);
i++; alias++;
}
}
lua_settable(L, resolved);
i = 1;
lua_newtable(L);
addr = (struct in_addr **) hp->h_addr_list;
if (addr) {
while (*addr) {
lua_pushnumber(L, i);
lua_pushstring(L, inet_ntoa(**addr));
lua_settable(L, -3);
i++; addr++;
}
}
lua_settable(L, resolved);
}

View File

@ -10,7 +10,7 @@
-----------------------------------------------------------------------------
local string = require("string")
local table = require("table")
local base = require("base")
local base = _G
module("ltn12")
filter = {}

View File

@ -89,12 +89,12 @@ static int base_open(lua_State *L) {
/* export functions (and leave namespace table on top of stack) */
luaL_openlib(L, "socket", func, 0);
#ifdef LUASOCKET_DEBUG
lua_pushstring(L, "DEBUG");
lua_pushstring(L, "_DEBUG");
lua_pushboolean(L, 1);
lua_rawset(L, -3);
#endif
/* make version string available to scripts */
lua_pushstring(L, "VERSION");
lua_pushstring(L, "_VERSION");
lua_pushstring(L, LUASOCKET_VERSION);
lua_rawset(L, -3);
return 1;

View File

@ -8,8 +8,7 @@
-----------------------------------------------------------------------------
-- Declare module and import dependencies
-----------------------------------------------------------------------------
package.loaded.base = _G
local base = require("base")
local base = _G
local ltn12 = require("ltn12")
local mime = require("cmime")
module("mime")

View File

@ -8,7 +8,7 @@
-----------------------------------------------------------------------------
-- Declare module and import dependencies
-----------------------------------------------------------------------------
local base = require("base")
local base = _G
local coroutine = require("coroutine")
local string = require("string")
local math = require("math")
@ -216,7 +216,7 @@ local function adjust_headers(mesgt)
end
lower["date"] = lower["date"] or
os.date("!%a, %d %b %Y %H:%M:%S ") .. (mesgt.zone or ZONE)
lower["x-mailer"] = lower["x-mailer"] or socket.VERSION
lower["x-mailer"] = lower["x-mailer"] or socket._VERSION
-- this can't be overriden
lower["mime-version"] = "1.0"
mesgt.headers = lower

View File

@ -7,8 +7,7 @@
-----------------------------------------------------------------------------
-- Declare module and import dependencies
-----------------------------------------------------------------------------
package.loaded.base = _G
local base = require("base")
local base = _G
local string = require("string")
local math = require("math")
local socket = require("csocket")

View File

@ -8,7 +8,7 @@
-----------------------------------------------------------------------------
-- Declare module and import dependencies
-----------------------------------------------------------------------------
local base = require("base")
local base = _G
local string = require("string")
local socket = require("socket")
local ltn12 = require("ltn12")

View File

@ -9,7 +9,7 @@
-- Declare module
-----------------------------------------------------------------------------
local string = require("string")
local base = require("base")
local base = _G
local table = require("table")
module("socket.url")

View File

@ -69,7 +69,7 @@ function check_timeout(tm, sl, elapsed, err, opp, mode, alldone)
end
end
if not socket.DEBUG then
if not socket._DEBUG then
fail("Please define LUASOCKET_DEBUG and recompile LuaSocket")
end