Permalink
Browse files

Merge from unstable

  • Loading branch information...
2 parents 9a1ae29 + 8692d0a commit a8f9003febd5df1b8cfe7cd0823de3f3e410ffc7 @drahosp drahosp committed Jul 31, 2012
Showing with 3,721 additions and 1,784 deletions.
  1. +3 −0 .gitignore
  2. +27 −5 CMakeLists.txt
  3. +5 −6 FIX
  4. +2 −2 LICENSE
  5. +34 −10 NEW
  6. +2 −2 README
  7. +53 −0 TODO
  8. +0 −60 config
  9. +60 −9 doc/dns.html
  10. +7 −7 doc/ftp.html
  11. +17 −18 doc/http.html
  12. +37 −62 doc/index.html
  13. +28 −58 doc/installation.html
  14. +4 −4 doc/introduction.html
  15. +4 −4 doc/ltn12.html
  16. +9 −9 doc/mime.html
  17. +24 −11 doc/reference.html
  18. +13 −13 doc/smtp.html
  19. +65 −18 doc/socket.html
  20. +160 −31 doc/tcp.html
  21. +146 −23 doc/udp.html
  22. +12 −13 doc/url.html
  23. +0 −1 etc/b64.lua
  24. +0 −1 etc/check-links.lua
  25. +22 −23 etc/dict.lua
  26. +1 −2 etc/dispatch.lua
  27. +0 −1 etc/eol.lua
  28. +53 −54 etc/get.lua
  29. +4 −5 etc/lp.lua
  30. +0 −1 etc/qp.lua
  31. +34 −35 etc/tftp.lua
  32. +0 −9 gem/makefile
  33. +16 −28 luasocket.sln
  34. +15 −42 makefile
  35. +5 −2 makefile.dist
  36. +121 −55 mime.vcproj
  37. +1 −1 samples/cddb.lua
  38. +0 −1 samples/daytimeclnt.lua
  39. +0 −1 samples/echoclnt.lua
  40. +0 −1 samples/echosrvr.lua
  41. +0 −1 samples/listener.lua
  42. +18 −0 samples/mclisten.lua
  43. +20 −0 samples/mcsend.lua
  44. +0 −1 samples/talker.lua
  45. +0 −1 samples/tinyirc.lua
  46. +147 −70 socket.vcproj
  47. +13 −4 src/auxiliar.c
  48. +2 −3 src/auxiliar.h
  49. +16 −8 src/buffer.c
  50. +2 −4 src/buffer.h
  51. +1 −3 src/except.c
  52. +0 −2 src/except.h
  53. +2 −3 src/ftp.lua
  54. +99 −0 src/headers.lua
  55. +6 −5 src/http.lua
  56. +183 −67 src/inet.c
  57. +7 −9 src/inet.h
  58. +0 −2 src/io.c
  59. +0 −2 src/io.h
  60. +0 −1 src/ltn12.lua
  61. +2 −4 src/luasocket.c
  62. +6 −4 src/luasocket.h
  63. +237 −60 src/makefile
  64. +20 −20 src/mbox.lua
  65. +45 −41 src/mime.c
  66. +2 −4 src/mime.h
  67. +0 −2 src/mime.lua
  68. +129 −16 src/options.c
  69. +25 −14 src/options.h
  70. +35 −19 src/select.c
  71. +0 −2 src/select.h
  72. +183 −0 src/serial.c
  73. +5 −4 src/smtp.lua
  74. +4 −2 src/socket.h
  75. +52 −17 src/socket.lua
  76. +184 −55 src/tcp.c
  77. +1 −2 src/tcp.h
  78. +16 −6 src/timeout.c
  79. +0 −2 src/timeout.h
  80. +2 −2 src/tp.lua
  81. +109 −39 src/udp.c
  82. +1 −2 src/udp.h
  83. +15 −31 src/unix.c
  84. +1 −3 src/unix.h
  85. +70 −65 src/url.lua
  86. +96 −13 src/usocket.c
  87. +4 −2 src/usocket.h
  88. +4 −6 src/wsocket.c
  89. +6 −3 src/wsocket.h
  90. +2 −0 test/README
  91. +32 −0 test/find-connect-limit
  92. +4 −4 test/ftptest.lua
  93. +3 −0 test/hello.lua
  94. +99 −99 test/httptest.lua
  95. +24 −0 test/mimetest.lua
  96. +52 −52 test/smtptest.lua
  97. +41 −0 test/tcp-getoptions
  98. +136 −54 test/testclnt.lua
  99. +73 −0 test/testing_thread.c
  100. +2 −0 test/testmesg.lua
  101. +7 −2 test/testsrvr.lua
  102. +7 −7 test/testsupport.lua
  103. +25 −0 test/udp-zero-length-send
  104. +37 −0 test/udp-zero-length-send-recv
  105. +422 −311 test/urltest.lua
  106. +1 −1 test/utestclnt.lua
View
@@ -0,0 +1,3 @@
+*.o
+*.so
+*.so.*
View
@@ -1,5 +1,5 @@
# Copyright (C) 2007-2012 LuaDist.
-# Created by Peter Drahoš
+# Created by Peter Drahoš, David Manura
# Redistribution and use of this file is allowed according to the terms of the MIT license.
# For details see the COPYRIGHT file distributed with LuaDist.
# Please note that the package source code is licensed under its own license.
@@ -39,6 +39,7 @@ install_lua_module ( ltn12 src/ltn12.lua )
install_lua_module ( mime src/mime.lua )
install_lua_module ( socket src/socket.lua )
install_lua_module ( socket.ftp src/ftp.lua )
+install_lua_module ( socket.headers src/headers.lua )
install_lua_module ( socket.http src/http.lua )
install_lua_module ( socket.smtp src/smtp.lua )
install_lua_module ( socket.tp src/tp.lua )
@@ -50,8 +51,29 @@ install_example ( samples/ )
install_doc ( doc/ )
install_data ( README NEW LICENSE )
-#2DO: how to spawn testsvr.lua to run in parallel with testclnt.lua?
-#~ add_lua_test ( test/testclnt.lua )
-file ( WRITE t/t.lua " require 'socket' " )
# very basic test
-add_lua_test ( t/t.lua )
+file ( WRITE ${CMAKE_CURRENT_BINARY_DIR}/t/t.lua " require 'socket' " )
+add_lua_test ( ${CMAKE_CURRENT_BINARY_DIR}/t/t.lua )
+
+# test with client-server.
+# This is more complicated because the test suite client and server must be
+# run in different threads (or different processes).
+find_package ( Threads )
+if ( Threads_FOUND )
+ add_lua_module ( testing_thread test/testing_thread.c LINK ${CMAKE_THREAD_LIBS_INIT} )
+ file ( WRITE ${CMAKE_CURRENT_BINARY_DIR}/t/clientserver.lua "
+ local socket = require 'socket'
+ function sleep(sec) socket.select(nil, nil, sec) end
+ print('RUN_THREAD=', RUN_THREAD)
+ if RUN_THREAD then
+ dofile '${CMAKE_CURRENT_SOURCE_DIR}/test/testsrvr.lua'
+ else
+ require 'testing_thread' '${CMAKE_CURRENT_BINARY_DIR}/clientserver.lua'
+ sleep(2) -- allow some time for server to start
+ dofile '${CMAKE_CURRENT_SOURCE_DIR}/test/testclnt.lua'
+ end
+ " )
+ add_lua_test ( ${CMAKE_CURRENT_BINARY_DIR}/t/clientserver.lua )
+else ()
+ message ( WARNING "skipping tests (no threading)" )
+endif ()
View
11 FIX
@@ -1,15 +1,14 @@
-http was preserving old host header during redirects
-fix smtp.send hang on source error
-add create field to FTP and SMTP and fix HTTP ugliness
-clean timeout argument to open functions in SMTP, HTTP and FTP
-eliminate globals from namespaces created by module().
-
+http was preserving old host header during redirects
+fix smtp.send hang on source error
+add create field to FTP and SMTP and fix HTTP ugliness
+clean timeout argument to open functions in SMTP, HTTP and FTP
+eliminate globals from namespaces created by module().
url.absolute was not working when base_url was already parsed
http.request was redirecting even when the location header was empty
tcp{client}:shutdown() was checking for group instead of class.
View
@@ -1,5 +1,5 @@
-LuaSocket 2.0.2 license
-Copyright � 2004-2007 Diego Nehab
+LuaSocket 2.1 license
+Copyright � 2004-2012 Diego Nehab
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
View
44 NEW
@@ -2,13 +2,37 @@ What's New
This is just a bug-fix/update release.
- * Improved: http.request() now supports deprecated HTTP/0.9
- servers (Florian Berger)
- * Fixed: could return "timedout" instead of "timeout" (Leo Leo)
- * Fixed: crash when reading '*a' on closed socket (Paul Ducklin);
- * Fixed: return values are consistent when reading from closed sockets;
- * Fixed: case sensitivity in headers of multipart messages in
- smtp.message() (Graham Henstridge);
- * Fixed a couple instances of error() being called instead of base.error(). These would cause an error when an error was reported. :) (Ketmar Dark);
- * Fixed: test script now uses pairs() iterator instead of the old
- Lua syntax (Robert Dodier).
+ * Fixed: manual sample of HTTP authentication now uses correct
+ "authorization" header (Alexandre Ittner);
+ * Fixed: failure on bind() was destroying the socket (Sam Roberts);
+ * Fixed: receive() returns immediatelly if prefix can satisfy
+ bytes requested (M Joonas Pihlaja);
+ * Fixed: multicast didn't work on Windows, or anywhere
+ else for that matter (Herbert Leuwer, Adrian Sietsma);
+ * Fixed: select() now reports an error when called with more
+ sockets than FD_SETSIZE (Lorenzo Leonini);
+ * Fixed: manual links to home.html changed to index.html (Robert Hahn);
+ * Fixed: mime.unb64() would return an empty string on results that started
+ with a null character (Robert Raschke);
+ * Fixed: HTTP now automatically redirects on 303 and 307 (Jonathan Gray);
+ * Fixed: calling sleep() with negative numbers could
+ block forever, wasting CPU. Now it returns immediately (MPB);
+ * Improved: FTP commands are now sent in upper case to
+ help buggy servers (Anders Eurenius);
+ * Improved: known headers now sent in canonic
+ capitalization to help buggy servers (Joseph Stewart);
+ * Improved: Clarified tcp:receive() in the manual (MPB);
+ * Improved: Decent makefiles (LHF).
+ * Fixed: RFC links in documentation now point to IETF (Cosmin Apreutesei).
+
+
+ Yuri's bug?
+ Dahlberg
+ Sam Roberts
+ Thomas Harning Jr.
+ Sebastien Perin
+ remove getn in all files
+ ltn12.pump.all(
+ ltn12.source.file(io.open("original.png")),
+ ltn12.sink.file(io.open("copy.png", "wb"))
+ )
View
4 README
@@ -1,5 +1,5 @@
-This is the LuaSocket 2.0.1. It has been tested on WinXP, Mac OS X,
-and Linux. Please use the Lua mailing list to report any bugs
+This is the LuaSocket 2.1. It has been tested on --[[WinXP--]], Mac OS X,
+and --[[Linux--]]. Please use the Lua mailing list to report any bugs
(or "features") you encounter.
Have fun,
View
53 TODO
@@ -1,3 +1,56 @@
+- document the new bind and connect behavior.
+- shouldn't we instead make the code compatible to Lua 5.2
+ without any compat stuff, and use a compatibility layer to
+ make it work on 5.1?
+- add what's new to manual
+- should there be an equivalent to tohostname for IPv6?
+- should we add service name resolution as well to getaddrinfo?
+- Maybe the sockaddr to presentation conversion should be done with getnameinfo()?
+
+- add http POST sample to manual
+ people keep asking stupid questions
+- documentation of dirty/getfd/setfd is problematic because of portability
+ same for unix and serial.
+ what to do about this? add a stronger disclaimer?
+- fix makefile with decent defaults?
+
+Done:
+
+- added IPv6 support to getsockname
+- simplified getpeername implementation
+- added family to return of getsockname and getpeername
+ and added modification to the manual to describe
+
+- connect and bind try all adresses returned by getaddrinfo
+- document headers.lua?
+- update copyright date everywhere?
+- remove RCSID from files?
+- move version to 2.1 rather than 2.1.1?
+- fixed url package to support ipv6 hosts
+- changed domain to family
+- implement getfamily methods.
+
+- remove references to Lua 5.0 from documentation, add 5.2?
+- update lua and luasocket version in samples in documentation
+- document ipv5_v6only default option being set?
+- document tcp6 and udp6
+- document dns.getaddrinfo
+- documented zero-sized datagram change?
+ no.
+- document unix socket and serial socket? add raw support?
+ no.
+- document getoption
+- merge luaL_typeerror into auxiliar to avoid using luaL prefix?
+
+
+
+
+
+
+
+
+
+
replace \r\n with \0xD\0xA in everything
New mime support
View
60 config
@@ -1,60 +0,0 @@
-#------
-# LuaSocket makefile configuration
-#
-
-#------
-# Output file names
-#
-EXT=so
-SOCKET_V=2.0.2
-MIME_V=1.0.2
-SOCKET_SO=socket.$(EXT).$(SOCKET_V)
-MIME_SO=mime.$(EXT).$(MIME_V)
-UNIX_SO=unix.$(EXT)
-
-#------
-# Lua includes and libraries
-#
-#LUAINC=-I/usr/local/include/lua50
-#LUAINC=-I/usr/local/include/lua5.1
-#LUAINC=-Ilua-5.1.1/src
-
-#------
-# Compat-5.1 directory
-#
-#COMPAT=compat-5.1r5
-
-#------
-# Top of your Lua installation
-# Relative paths will be inside the src tree
-#
-#INSTALL_TOP_SHARE=/usr/local/share/lua/5.0
-#INSTALL_TOP_LIB=/usr/local/lib/lua/5.0
-INSTALL_TOP_SHARE=/usr/local/share/lua/5.1
-INSTALL_TOP_LIB=/usr/local/lib/lua/5.1
-
-INSTALL_DATA=cp
-INSTALL_EXEC=cp
-
-#------
-# Compiler and linker settings
-# for Mac OS X
-#
-#CC=gcc
-#DEF= -DLUASOCKET_DEBUG -DUNIX_HAS_SUN_LEN
-#CFLAGS= $(LUAINC) -I$(COMPAT) $(DEF) -pedantic -Wall -O2 -fno-common
-#LDFLAGS=-bundle -undefined dynamic_lookup
-#LD=export MACOSX_DEPLOYMENT_TARGET="10.3"; gcc
-
-#------
-# Compiler and linker settings
-# for Linux
-CC=gcc
-DEF=-DLUASOCKET_DEBUG
-CFLAGS= $(LUAINC) $(DEF) -pedantic -Wall -O2 -fpic
-LDFLAGS=-O -shared -fpic
-LD=gcc
-
-#------
-# End of makefile configuration
-#
View
@@ -24,8 +24,8 @@
</td></tr>
</table>
<p class=bar>
-<a href="home.html">home</a> &middot;
-<a href="home.html#download">download</a> &middot;
+<a href="index.html">home</a> &middot;
+<a href="index.html#download">download</a> &middot;
<a href="installation.html">installation</a> &middot;
<a href="introduction.html">introduction</a> &middot;
<a href="reference.html">reference</a>
@@ -39,12 +39,16 @@
<h2 id=dns>DNS</h2>
<p>
-Name resolution functions return <em>all</em> information obtained from the
-resolver in a table of the form:
+IPv4 name resolution functions
+<a href=#toip><tt>dns.toip</tt></a>
+and
+<a href=#tohostname><tt>dns.tohostname</tt></a>
+return <em>all</em> information obtained from
+the resolver in a table of the form:
</p>
<blockquote><tt>
-resolved = {<br>
+resolved4 = {<br>
&nbsp;&nbsp;name = <i>canonic-name</i>,<br>
&nbsp;&nbsp;alias = <i>alias-list</i>,<br>
&nbsp;&nbsp;ip = <i>ip-address-list</i><br>
@@ -55,6 +59,53 @@ <h2 id=dns>DNS</h2>
Note that the <tt>alias</tt> list can be empty.
</p>
+<p>
+The more general name resolution function
+<a href=#getaddrinfo><tt>dns.getaddrinfo</tt></a>, which
+supports both IPv6 and IPv4,
+returns <em>all</em> information obtained from
+the resolver in a table of the form:
+</p>
+
+<blockquote><tt>
+resolved6 = {<br>
+&nbsp;&nbsp;[1] = {<br>
+&nbsp;&nbsp;&nbsp;&nbsp;family = <i>family-name-1</i>,<br>
+&nbsp;&nbsp;&nbsp;&nbsp;addr = <i>address-1</i><br>
+&nbsp;&nbsp;},<br>
+&nbsp;&nbsp;...<br>
+&nbsp;&nbsp;[n] = {<br>
+&nbsp;&nbsp;&nbsp;&nbsp;family = <i>family-name-n</i>,<br>
+&nbsp;&nbsp;&nbsp;&nbsp;addr = <i>address-n</i><br>
+&nbsp;&nbsp;}<br>
+}
+</tt> </blockquote>
+
+<p>
+Here, <tt>family</tt> contains the string <tt>"inet"</tt> for IPv4
+addresses, and <tt>"inet6"</tt> for IPv6 addresses.
+</p>
+
+<!-- getaddrinfo ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
+
+<p class=name id=getaddrinfo>
+socket.dns.<b>getaddrinfo(</b>address<b>)</b>
+</p>
+
+<p class=description>
+Converts from host name to address.
+</p>
+
+<p class=parameters>
+<tt>Address</tt> can be an IPv4 or IPv6 address or host name.
+</p>
+
+<p class=return>
+The function returns a table with all information returned by
+the resolver. In case of error, the function returns <b><tt>nil</tt></b>
+followed by an error message.
+</p>
+
<!-- gethostname ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<p class=name id=gethostname>
@@ -72,7 +123,7 @@ <h2 id=dns>DNS</h2>
</p>
<p class=description>
-Converts from IP address to host name.
+Converts from IPv4 address to host name.
</p>
<p class=parameters>
@@ -93,7 +144,7 @@ <h2 id=dns>DNS</h2>
</p>
<p class=description>
-Converts from host name to IP address.
+Converts from host name to IPv4 address.
</p>
<p class=parameters>
@@ -113,8 +164,8 @@ <h2 id=dns>DNS</h2>
<hr>
<center>
<p class=bar>
-<a href="home.html">home</a> &middot;
-<a href="home.html#down">download</a> &middot;
+<a href="index.html">home</a> &middot;
+<a href="index.html#down">download</a> &middot;
<a href="installation.html">installation</a> &middot;
<a href="introduction.html">introduction</a> &middot;
<a href="reference.html">reference</a>
Oops, something went wrong.

0 comments on commit a8f9003

Please sign in to comment.