diff --git a/TODO b/TODO index f6a67f1..4dd0766 100644 --- a/TODO +++ b/TODO @@ -1,4 +1,5 @@ manual + check all occurences of it's add shutdown add gethostname the need of a content-length header in the post method... @@ -22,6 +23,11 @@ tests checar garbage collection check for interrupts +close has to block... +fmt is not a good name +change wrap() to accept a number and default to "character" +move gethostname to dns table +get rid of _cb in name of functions? trust character constants in mime.c? noooooo. smtp.lua needs stuff filter diff --git a/doc/callback.html b/doc/callback.html index 2c7ecd5..94af8ff 100644 --- a/doc/callback.html +++ b/doc/callback.html @@ -45,113 +45,72 @@ callback mechanism outlined below.

-Instead of returning the entire contents of an entity -as strings to the Lua application, the library allows the user to +Instead of returning the received contents +as a big to the Lua application, the library allows the user to provide a receive callback that will be called with successive chunks of data, as the data becomes available. Conversely, the send -callbacks can be used when the application wants to incrementally -provide LuaSocket with the data to be sent. +callback mechanism can be used when the application wants to incrementally provide LuaSocket with the data to be sent.

-

-ret, err_or_f = receive_cb(chunk, err) +

+receive_cb(chunk, err)

-The callback provided by the user will be repeatedly called by the -library whenever new data is available. Each time it is called, the -callback receives successive chunks of downloaded data. +A receive callback will be repeatedly called by +LuaSocket wheneve new data is available. Each time it is called, the +callback receives successive chunks of downloaded data.

-Chunk contains the current chunk of data. -When the transmission is over, the function is called with an -empty string (i.e. "") as the chunk. -If an error occurs, the function receives nil -as chunk and an error message in err. +Chunk contains the latest downloaded chunk of data. +When the transmission is over, the function is called with an +empty string (i.e. "") in chunk. +If an error occurs, the function receives a nil +chunk and an error message in err.

-The callback can abort transmission by returning nil as its first -return value, and an optional error message as the -second return value. If the application wants to continue receiving -data, the function should return non-nil as it's first return -value. In this case, the function can optionally return a -new callback function, to replace itself, as the second return value. -

- -

-Note: The callback module provides several standard receive callbacks, including the following: -

- -
-function receive.concat(concat)
-    concat = concat or socket.concat.create()
-    local callback = function(chunk, err)
-        -- if not finished, add chunk
-        if chunk and chunk ~= "" then
-            concat:addstring(chunk)
-            return 1
-        end
-    end
-    return callback, concat
-end
-
- -

-This function creates a new receive callback that concatenates all -received chunks into a the same concat object, which can later be -queried for its contents. +The callback can abort transmission by returning nil as its first +return value, and an optional error message as the +second return value. To continue receiving +data, the function should return non-nil as its first return +value. Optionally, in this case, it may return a +second return value, with a new callback function to take its place.

-

-chunk, err_or_r = send_cb() +

+send_cb()

-The callback provided by the user will be repeatedly called whenever the -library needs more data to be sent. +A send callback will be called whenever LuaSocket +needs more data to be sent.

Each time the callback is called, it should return the next chunk of data. It can optionally return, as it's second return value, a new callback to replace itself. The callback can abort the process at any time by returning -nil followed by an optional error message. +nil followed by an optional error message.

-

-Note: Below is the implementation of the callback.send.file -function. Given an open file handle, it returns a send callback that will send the contents of that file, chunk by chunk. -

- -
-function send.file(file, io_err)
-    -- if successful, return the callback that reads from the file
-    if file then
-        return function()
-            -- send next block of data
-            return (file:read(BLOCKSIZE)) or ""
-        end
-    -- else, return a callback that just aborts the transfer
-    else return fail(io_err or "unable to open file") end
-end
-
-

Predefined Callbacks

-The module callback.lua provides several predefined callbacks to +The Callback module provides several predefined callbacks to perform the most common input/output operations. Callbacks are provided that send and receive contents of files and strings. Furthermore, composition functions are provided to chain callbacks with filters, such as -the filters defined in the mime.lua module. +the filters defined in the MIME module. +Together, these two modules provide a powerful interface to send and +receive information.

@@ -161,15 +120,16 @@ the filters defined in the mime.lua module.

-This function creates a send callback that will return the contents -of a the file, until the file has been entirely sent. When done, the -callback closes the file. +This function creates a send callback that returns the contents +of a file, chunk by chunk, until the file has been entirely sent. +When done, the callback closes the file.

-File is a file open for reading. If file is -nil, io_err can contain an error message and the -returned callback just aborts transmission with the error message. +File is a file opened for reading. If file is +nil, io_err can contain an error message. In this +case, the function returns a callback that just aborts +transmission with the error message.

@@ -177,14 +137,14 @@ Returns a send callback for the file.

-Note: The function is designed so that it directly accepts the return +Note: This function is designed so that it directly accepts the return values of the io.open function.

-send.string(str) +send.string(str, err)

@@ -193,29 +153,33 @@ the contents of a string.

-Str is the string to be sent. +Str is the string to be sent. +

-Returns a send callback for the string, or nil if the string is -nil. +Returns a send callback for the string, or nil if the string is +nil.

-Note: If any function in the LuaSocket API receives a nil -send callback, it assumes there is nothing to be sent. +Note: A nil +send callback is equivalent to a callback that returns the empty string.

-

+

send.chain(send_cb, filter)

-This function creates a send callback that will send -all data that it gets from another callback, -after passing the data through a filter. +This function creates a send callback that will filter +all the data it receives from another send callback, before +sending it through.

@@ -226,7 +190,29 @@ after passing the data through a filter. Returns a callback chained with the filter.

-(write a note!) +

+Note: Several filters are defined in the MIME +module. Below is an example that creates a send callback that sends +a file's contents encoded in the Base64 transfer content encoding. +

+ +
+send_cb = socket.callback.send.chain(
+   socket.callback.send.file(io.open("input.bin"))
+   socket.mime.chain(
+       socket.mime.encode("base64"),
+       socket.mime.wrap("base64")
+   )
+)
+
+ +

+The call to socket.mime.chain +creates a chained filter that encodes it's input and then breaks it +into lines. The call to socket.callback.chain creates a chained +send callback that reads the file from disk and passes it through the +filter before sending it. +

diff --git a/doc/code.html b/doc/code.html index 45fd21a..4668b7a 100644 --- a/doc/code.html +++ b/doc/code.html @@ -59,7 +59,7 @@ Applies the Base 64 content coding to a string.

Content is the string to be encoded. If single is set to anything -but nil, the output is returned as a single +but nil, the output is returned as a single line, otherwise the function splits the content into 76 character long lines after encoding.

diff --git a/doc/dns.html b/doc/dns.html index 6abf341..17cee45 100644 --- a/doc/dns.html +++ b/doc/dns.html @@ -70,7 +70,7 @@ Converts from IP address to host name.

The function a string with the canonic host name of the given address, followed by a table with all information returned by -the resolver. In case of error, the function returns nil +the resolver. In case of error, the function returns nil followed by an error message.

@@ -92,7 +92,7 @@ Converts from host name to IP address.

Returns a string with the first IP address found for address, followed by a table with all information returned by the resolver. -In case of error, the function returns nil followed by an error +In case of error, the function returns nil followed by an error message.

diff --git a/doc/ftp.html b/doc/ftp.html index 8072afe..6776a17 100644 --- a/doc/ftp.html +++ b/doc/ftp.html @@ -88,7 +88,7 @@ determines the transfer type. If <path> ends with a

If successful, the function returns the file content as a string. In case of error, the function returns -nil and an error message describing the error. +nil and an error message describing the error.

@@ -165,7 +165,7 @@ function tries to log in as 'anonymous'.
 
 

If successful, the function returns 1. In case of error, the -function returns nil followed by a string describing the error. +function returns nil followed by a string describing the error.

diff --git a/doc/http.html b/doc/http.html
index b7469a4..f977ea9 100644
--- a/doc/http.html
+++ b/doc/http.html
@@ -203,7 +203,7 @@ request message. If authentication information is provided, the function
 uses the  Basic Authentication Scheme (see  note)
 to retrieve  the document. User and  password provided
 explicitly override  those given by the  url. The stay
-parameter, when set to anything  but nil, prevents the function
+parameter, when set to anything  but nil, prevents the function
 from automatically following 301 or 302 server redirect messages. 
 

@@ -333,7 +333,7 @@ Authentication Scheme (see note) to retrieve the document. Request.user and request.password override those given by the request.url. The request.stay parameter, when set to -anything but nil, prevents the function from automatically +anything but nil, prevents the function from automatically following 301 or 302 server redirect messages.

diff --git a/doc/reference.css b/doc/reference.css index 2a8987e..607ac4f 100644 --- a/doc/reference.css +++ b/doc/reference.css @@ -1,11 +1,19 @@ -body { margin-left: 1em; margin-right: 1em; } +body { + margin-left: 1em; + margin-right: 1em; + font-family: "Verdana"; +} + +tt { + font-family: "Andale Mono", monospace; +} h1, h2, h3, h4 { margin-left: 0em; } p { margin-left: 1em; } p.name { - font-family: monospace; + font-family: "Andale Mono", monospace; padding-top: 1em; margin-left: 0em; } @@ -18,6 +26,8 @@ pre.example { background: #ccc; padding: 1em; margin-left: 1em; + font-family: "Andale Mono", monospace; + font-size: small; } hr { diff --git a/doc/reference.html b/doc/reference.html index 99b1ea7..0bfd378 100644 --- a/doc/reference.html +++ b/doc/reference.html @@ -35,155 +35,173 @@

Reference

- + - - - - - - +
+Callbacks (socket.callback) +
+send: +chain, +file, +string. +
+
+receive: +chain, +file, +concat. +
+
-
+ + +
+DNS services (socket.dns) +
+toip, +tohostname, +gethostname. +
+
+ + + +
+FTP (socket.ftp) +
+get, +get_cb, +put, +put_cb. +
+
+ + + +
+Globals (socket) +
+bind, +callback, +concat, +connect, +debug, +dns, +ftp, +http, +mime, +select, +sleep, +smtp, +time, +tcp. +udp, +url, +version. +
+
+ + + + + +
+HTTP (socket.http) +
+get, +post, +request, +request_cb. +
+
+ + + +
+MIME (socket.mime) +
+filters: +canonic, +chain, +decode, +encode, +wrap. +
+
+low-level: +b64, +unb64, +eol, +qp, +unqp, +wrp, +qpwrp. +
+
+ + + +
+SMTP (socket.smtp) +
+mail +
+
+ + + +
+TCP (socket.tcp) +
+accept, +bind, +close, +connect, +getpeername, +getsockname, +receive, +send, +setoption, +settimeout, +shutdown. +
+
- - - - - - -
+
+UDP (socket.udp) +
+close, +getpeername, +getsockname, +receive, +receivefrom, +send, +sendto, +setpeername, +setsockname, +setoption, +settimeout, +shutdown. +
+
-
+ - - - - - - - - -
- -
- - - - - - -
- -
- - - - - - - - - -
- -
- - - - - - - - - -
+
+URL (socket.url) +
+absolute, +build, +build_path, +quote, +parse, +parse_path, +unquote. +
+
diff --git a/doc/smtp.html b/doc/smtp.html index aa92149..0862de0 100644 --- a/doc/smtp.html +++ b/doc/smtp.html @@ -105,7 +105,7 @@ and text body. The message is sent using the server

If successful, the function returns 1. Otherwise, the function returns -nil followed by an error message. +nil followed by an error message.

diff --git a/doc/stream.html b/doc/stream.html index b88cbb5..585ad18 100644 --- a/doc/stream.html +++ b/doc/stream.html @@ -69,15 +69,15 @@ callback receives successive chunks of downloaded data. Chunk contains the current chunk of data. When the transmission is over, the function is called with an empty string (i.e. "") as the chunk. -If an error occurs, the function receives nil +If an error occurs, the function receives nil as chunk and an error message in err.

-The callback can abort transmission by returning nil as its first +The callback can abort transmission by returning nil as its first return value, and an optional error message as the second return value. If the application wants to continue receiving -data, the function should return non-nil as it's first return +data, the function should return non-nil as it's first return value. In this case, the function can optionally return a new callback function, to replace itself, as the second return value.

@@ -121,7 +121,7 @@ library needs more data to be sent. Each time the callback is called, it should return the next chunk of data. It can optionally return, as it's second return value, a new callback to replace itself. The callback can abort the process at any time by returning -nil followed by an optional error message. +nil followed by an optional error message.

diff --git a/doc/tcp.html b/doc/tcp.html index 0be535a..eb4cdfa 100644 --- a/doc/tcp.html +++ b/doc/tcp.html @@ -51,7 +51,7 @@ method.

In case of success, a new master object is returned. In case of error, -nil is returned, followed by an error message. +nil is returned, followed by an error message.

@@ -67,7 +67,7 @@ object and returns a client object representing that connection.

If a connection is successfully initiated, a client object is returned. -If a timeout condition is met, the method returns nil followed +If a timeout condition is met, the method returns nil followed by the error string 'timeout'.

@@ -111,7 +111,7 @@ attempts connection, the connection is refused.

In case of success, the method returns 1. In case of error, the -method returns nil followed by an error message. +method returns nil followed by an error message.

@@ -165,7 +165,7 @@ and close.

-In case of error, the method returns nil followed by a string +In case of error, the method returns nil followed by a string describing the error. In case of success, the method returns 1.

@@ -187,7 +187,7 @@ Returns information about the remote side of a connected client object.

Returns a string with the IP address of the peer, followed by the port number that peer is using for the connection. -In case of error, the method returns nil. +In case of error, the method returns nil.

@@ -207,7 +207,7 @@ Returns the local address information associated to the object.

The method returns a string with local IP address and a number with -the port. In case of error, the method returns nil. +the port. In case of error, the method returns nil.

@@ -248,7 +248,7 @@ bytes from the socket.

The method returns one value for each pattern, followed by a single -error code that can be nil in case of success, the string +error code that can be nil in case of success, the string 'closed' in case the connection was closed before the transmission was completed or the string 'timeout' in case there was a timeout during the operation. @@ -278,7 +278,7 @@ result to LuaSocket instead of passing several independent strings.

The method returns the number of bytes accepted by the transport layer, -followed by an error code. The error code is nil if the operation +followed by an error code. The error code is nil if the operation completed with no errors, the string 'closed' in case the connection was closed before the transmission was completed or the string 'timeout' in case there was a timeout during the @@ -288,7 +288,7 @@ operation.

Note: The return values for the send method have been changed in LuaSocket 2.0! In previous versions, the method returned only the -error message. Since returning nil in case of success goes +error message. Since returning nil in case of success goes against all other LuaSocket methods and functions, the send method been changed for the sake of uniformity.

@@ -330,7 +330,7 @@ considered broken and processes using the socket are notified.

-The method returns 1 in case of success, or nil otherwise. +The method returns 1 in case of success, or nil otherwise.

@@ -374,7 +374,7 @@ a call.

-The nil timeout value allows operations to block +The nil timeout value allows operations to block indefinitely. Negative timeout values have the same effect.

diff --git a/doc/udp.html b/doc/udp.html index 7f2ecce..9f5cf8f 100644 --- a/doc/udp.html +++ b/doc/udp.html @@ -52,7 +52,7 @@ is used to connect the object.

In case of success, a new unconnected UDP object -returned. In case of error, nil is returned, followed by +returned. In case of error, nil is returned, followed by an error message.

@@ -112,7 +112,7 @@ Returns the local address information associated to the object.

The method returns a string with local IP address and a number with the port. In case of error, the method -returns nil. +returns nil.

@@ -150,7 +150,7 @@ maximum datagram size is used.

In case of success, the method return the received datagram. In case of timeout, the method returns -nil followed by the string 'timeout'. +nil followed by the string 'timeout'.

@@ -183,7 +183,7 @@ Beware that the maximum datagram size for UDP is 576 bytes.

If successful, the method returns 1. In case of -error, the method returns nil followed by the +error, the method returns nil followed by the 'refused' message.

@@ -214,7 +214,7 @@ names are not allowed for performance reasons.

If successful, the method returns 1. In case of -error, the method returns nil followed by the +error, the method returns nil followed by the 'refused' message.

@@ -258,7 +258,7 @@ case, the port argument is ignored.

In case of error the method returns -nil followed by an error message. In case of success, the +nil followed by an error message. In case of success, the method returns 1.

@@ -288,7 +288,7 @@ all local interfaces using the constant INADDR_ANY. If

If successful, the method returns 1. In case of -error, the method returns nil followed by an error +error, the method returns nil followed by an error message.

@@ -328,7 +328,7 @@ socket.

The method returns 1 in case of success, or -nil followed by an error message otherwise. +nil followed by an error message otherwise.

@@ -356,7 +356,7 @@ give up and fail with an error code.

The amount of time to wait is specified as -the value parameter, in seconds. The nil timeout +the value parameter, in seconds. The nil timeout value allows operations to block indefinitely. Negative timeout values have the same effect.

diff --git a/doc/url.html b/doc/url.html index e67ea13..0eafafa 100644 --- a/doc/url.html +++ b/doc/url.html @@ -148,7 +148,7 @@ component.

Segments is a list of strings with the <segment> -parts. If unsafe is anything but nil, reserved +parts. If unsafe is anything but nil, reserved characters are left untouched.

diff --git a/etc/b64.lua b/etc/b64.lua index 7a4607d..de83578 100644 --- a/etc/b64.lua +++ b/etc/b64.lua @@ -1,6 +1,11 @@ -local base64 = socket.mime.base64.encode() -local split = socket.mime.split() -local convert = socket.mime.chain(base64, split) +local convert +if arg and arg[1] == '-d' then + convert = socket.mime.decode("base64") +else + local base64 = socket.mime.encode("base64") + local wrap = socket.mime.wrap() + convert = socket.mime.chain(base64, wrap) +end while 1 do local chunk = io.read(4096) io.write(convert(chunk)) diff --git a/src/inet.c b/src/inet.c index dff4bf2..d626b86 100644 --- a/src/inet.c +++ b/src/inet.c @@ -19,11 +19,13 @@ static int inet_global_toip(lua_State *L); static int inet_global_tohostname(lua_State *L); static void inet_pushresolved(lua_State *L, struct hostent *hp); +static int inet_global_gethostname(lua_State *L); /* DNS functions */ static luaL_reg func[] = { { "toip", inet_global_toip }, { "tohostname", inet_global_tohostname }, + { "gethostname", inet_global_gethostname}, { NULL, NULL} }; @@ -101,6 +103,25 @@ static int inet_global_tohostname(lua_State *L) return 2; } +/*-------------------------------------------------------------------------*\ +* Gets the host name +\*-------------------------------------------------------------------------*/ +static int inet_global_gethostname(lua_State *L) +{ + char name[257]; + name[256] = '\0'; + if (gethostname(name, 256) < 0) { + lua_pushnil(L); + lua_pushstring(L, "gethostname failed"); + return 2; + } else { + lua_pushstring(L, name); + return 1; + } +} + + + /*=========================================================================*\ * Lua methods \*=========================================================================*/ diff --git a/src/luasocket.c b/src/luasocket.c index 73583a8..bfe71c2 100644 --- a/src/luasocket.c +++ b/src/luasocket.c @@ -38,15 +38,8 @@ /*=========================================================================*\ * Declarations \*=========================================================================*/ -static int global_gethostname(lua_State *L); static int base_open(lua_State *L); -/* functions in library namespace */ -static luaL_reg func[] = { - {"gethostname", global_gethostname}, - {NULL, NULL} -}; - /*-------------------------------------------------------------------------*\ * Setup basic stuff. \*-------------------------------------------------------------------------*/ @@ -70,29 +63,9 @@ static int base_open(lua_State *L) lua_pushstring(L, "LUASOCKET_LIBNAME"); lua_pushstring(L, LUASOCKET_LIBNAME); lua_settable(L, LUA_GLOBALSINDEX); - /* define library functions */ - luaL_openlib(L, LUASOCKET_LIBNAME, func, 0); - lua_pop(L, 1); return 0; } -/*-------------------------------------------------------------------------*\ -* Gets the host name -\*-------------------------------------------------------------------------*/ -static int global_gethostname(lua_State *L) -{ - char name[257]; - name[256] = '\0'; - if (gethostname(name, 256) < 0) { - lua_pushnil(L); - lua_pushstring(L, "gethostname failed"); - return 2; - } else { - lua_pushstring(L, name); - return 1; - } -} - /*-------------------------------------------------------------------------*\ * Initializes all library modules. \*-------------------------------------------------------------------------*/ diff --git a/src/mime.c b/src/mime.c index 8e97f8b..95cd400 100644 --- a/src/mime.c +++ b/src/mime.c @@ -27,12 +27,12 @@ static const char EQCRLF[3] = {'=', CR, LF}; /*=========================================================================*\ * Internal function prototypes. \*=========================================================================*/ -static int mime_global_fmt(lua_State *L); +static int mime_global_wrp(lua_State *L); static int mime_global_b64(lua_State *L); static int mime_global_unb64(lua_State *L); static int mime_global_qp(lua_State *L); static int mime_global_unqp(lua_State *L); -static int mime_global_qpfmt(lua_State *L); +static int mime_global_qpwrp(lua_State *L); static int mime_global_eol(lua_State *L); static void b64setup(UC *b64unbase); @@ -54,10 +54,10 @@ static luaL_reg func[] = { { "eol", mime_global_eol }, { "qp", mime_global_qp }, { "unqp", mime_global_unqp }, - { "qpfmt", mime_global_qpfmt }, + { "qpwrp", mime_global_qpwrp }, { "b64", mime_global_b64 }, { "unb64", mime_global_unb64 }, - { "fmt", mime_global_fmt }, + { "wrp", mime_global_wrp }, { NULL, NULL } }; @@ -127,13 +127,13 @@ static const char *optlstring(lua_State *L, int n, const char *v, size_t *l) \*=========================================================================*/ /*-------------------------------------------------------------------------*\ * Incrementaly breaks a string into lines -* A, n = fmt(l, B, length, marker) +* A, n = wrp(l, B, length, marker) * A is a copy of B, broken into lines of at most 'length' bytes. * 'l' is how many bytes are left for the first line of B. * 'n' is the number of bytes left in the last line of A. * Marker is the end-of-line marker. \*-------------------------------------------------------------------------*/ -static int mime_global_fmt(lua_State *L) +static int mime_global_wrp(lua_State *L) { size_t size = 0; int left = (int) luaL_checknumber(L, 1); @@ -526,14 +526,14 @@ static int mime_global_unqp(lua_State *L) /*-------------------------------------------------------------------------*\ * Incrementally breaks a quoted-printed string into lines -* A, n = qpfmt(l, B, length) +* A, n = qpwrp(l, B, length) * A is a copy of B, broken into lines of at most 'length' bytes. * 'l' is how many bytes are left for the first line of B. * 'n' is the number of bytes left in the last line of A. * There are two complications: lines can't be broken in the middle * of an encoded =XX, and there might be line breaks already \*-------------------------------------------------------------------------*/ -static int mime_global_qpfmt(lua_State *L) +static int mime_global_qpwrp(lua_State *L) { size_t size = 0; int left = (int) luaL_checknumber(L, 1); diff --git a/src/mime.lua b/src/mime.lua index 0251f6e..30c6b38 100644 --- a/src/mime.lua +++ b/src/mime.lua @@ -19,7 +19,7 @@ local wt = {} local function choose(table) return function(method, ...) local f = table[method or "nil"] - if not f then return nil, "unknown method (" .. tostring(method) .. ")" + if not f then error("unknown method (" .. tostring(method) .. ")", 3) else return f(unpack(arg)) end end end @@ -37,7 +37,15 @@ end -- function that choose the encoding, decoding or wrap algorithm encode = choose(et) decode = choose(dt) -wrap = choose(wt) + +-- the wrap filter has default parameters +local cwt = choose(wt) +function wrap(...) + if not arg[1] or type(arg[1]) ~= "string" then + table.insert(arg, 1, "base64") + end + return cwt(unpack(arg)) +end -- define the encoding algorithms et['base64'] = function() @@ -58,15 +66,14 @@ dt['quoted-printable'] = function() end -- define the wrap algorithms -wt['character'] = function(length) +wt['base64'] = function(length, marker) length = length or 76 - return cicle(fmt, length, length) + return cicle(wrp, length, length, marker) end -wt['base64'] = wt['character'] wt['quoted-printable'] = function(length) length = length or 76 - return cicle(qpfmt, length, length) + return cicle(qpwrp, length, length) end -- define the end-of-line translation function diff --git a/test/httptest.lua b/test/httptest.lua index 8bf3980..c9a74a8 100644 --- a/test/httptest.lua +++ b/test/httptest.lua @@ -12,7 +12,7 @@ socket.http.TIMEOUT = 5 local t = socket.time() -host = host or "diego.student.dyn.cs.princeton.edu" +host = host or "diego-interface2.student.dyn.CS.Princeton.EDU" proxy = proxy or "http://localhost:3128" prefix = prefix or "/luasocket-test" cgiprefix = cgiprefix or "/luasocket-test-cgi" diff --git a/test/mimetest.lua b/test/mimetest.lua index aa2772c..81814de 100644 --- a/test/mimetest.lua +++ b/test/mimetest.lua @@ -4,7 +4,7 @@ local qptest = "qptest.bin" local eqptest = "qptest.bin2" local dqptest = "qptest.bin3" -local b64test = "luasocket.exe" +local b64test = "luasocket" local eb64test = "b64test.bin" local db64test = "b64test.bin2" @@ -155,10 +155,10 @@ local function encode_b64test() local e2 = socket.mime.encode("base64") local e3 = socket.mime.encode("base64") local e4 = socket.mime.encode("base64") - local sp4 = socket.mime.wrap("character") - local sp3 = socket.mime.wrap("character", 59) - local sp2 = socket.mime.wrap("character", 30) - local sp1 = socket.mime.wrap("character", 27) + local sp4 = socket.mime.wrap() + local sp3 = socket.mime.wrap(59) + local sp2 = socket.mime.wrap("base64", 30) + local sp1 = socket.mime.wrap(27) local chain = socket.mime.chain(e1, sp1, e2, sp2, e3, sp3, e4, sp4) transform(b64test, eb64test, chain) end diff --git a/test/testclnt.lua b/test/testclnt.lua index beb0157..5f366b2 100644 --- a/test/testclnt.lua +++ b/test/testclnt.lua @@ -378,7 +378,7 @@ end ------------------------------------------------------------------------ function accept_errors() - io.write("not listenning: ") + io.write("not listening: ") local d, e = socket.bind("*", 0) assert(d, e); local c, e = socket.tcp(); @@ -392,7 +392,7 @@ function accept_errors() assert(c, e); d:setfd(c:getfd()) local r, e = d:accept() - assert(not r and e == "not supported", e) + assert(not r and e == "not supported" or e == "not listening", e) print("ok") end