diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ac8f968 --- /dev/null +++ b/.gitignore @@ -0,0 +1,20 @@ +# Compiled source # +################### +*.com +*.class +*.dll +*.exe +*.o +*.so +*.pyc + +# Logs and databases # +###################### +*.log + +# OS generated files # +###################### +.DS_Store* +ehthumbs.db +Icon? +Thumbs.db diff --git a/example/nginx/boundary.lua b/example/nginx/boundary.lua index 5aeb6f1..8b6c589 100644 --- a/example/nginx/boundary.lua +++ b/example/nginx/boundary.lua @@ -8,7 +8,7 @@ function get(ct) if not ct then return false end local _,_,boundary = string.find (ct, "boundary%=(.-)$") if not boundary then return false end - return "--"..boundary + return "--"..boundary end -- @@ -17,13 +17,13 @@ end function split(...) local request_data, boundary = ... - if not request_data then return false end; - if not boundary then return false end; + if not request_data then return false end; + if not boundary then return false end; local files, posts = {}, {} local post_temp = nginx.kit.split(request_data, boundary) - for i,pd in ipairs(post_temp) do + for i,pd in ipairs(post_temp) do local headers = {} local hdrdata, post_val = string.match(pd, "(.+)\r\n\r\n(.+)\r\n") @@ -48,13 +48,13 @@ function split(...) local file = {} file['type'] = headers["content-type"] file['name'] = t["filename"] - file['data'] = post_val; - file['size'] = string.len(post_val); + file['data'] = post_val; + file['size'] = string.len(post_val); files[t.name] = file else - posts[t.name] = post_val - end + posts[t.name] = post_val + end end end diff --git a/example/nginx/urlcode.lua b/example/nginx/urlcode.lua index 9a29f2b..da999a0 100644 --- a/example/nginx/urlcode.lua +++ b/example/nginx/urlcode.lua @@ -54,7 +54,7 @@ function insertfield (args, name, value) end ---------------------------------------------------------------------------- --- Parse url-encoded request data +-- Parse url-encoded request data -- (the query part of the script URL or url-encoded post data) -- -- Each decoded (name=value) pair is inserted into table [[args]] @@ -90,6 +90,6 @@ function encodetable (args) strp = strp.."&"..escape(key).."="..escape(val) end end - -- remove first & + -- remove first & return string.sub(strp,2) end diff --git a/example/t1.lua b/example/t1.lua index f765cdc..a6e4175 100644 --- a/example/t1.lua +++ b/example/t1.lua @@ -38,10 +38,10 @@ local f = io.open('/root/480x480.png', 'rb') f:close() --ngx.print(ngx.set_cookie) local t = os.time() -ngx.set_cookie('love1', "me") -- name, value, expire, path, domain, secure ---ngx.set_cookie('love2', "me", 100) -- name, value, expire, path, domain, secure ---ngx.set_cookie('love3', '123456') -- name, value, expire, path, domain, secure ---ngx.set_cookie('isopen', 'true', 1000, '/', '192.168.137.126') -- name, value, expire, path, domain, secure +ngx.set_cookie('love1', "me") -- name, value, expire, path, domain, secure +--ngx.set_cookie('love2', "me", 100) -- name, value, expire, path, domain, secure +--ngx.set_cookie('love3', '123456') -- name, value, expire, path, domain, secure +--ngx.set_cookie('isopen', 'true', 1000, '/', '192.168.137.126') -- name, value, expire, path, domain, secure ngx.set_header('X-Memc-Flags', "11111111111111"); ngx.set_header('X-Memc-Flags', "2222222222222222222222222"); ngx.set_header('X-Memc-Flags', "f1111122222222333333334444445"); diff --git a/example/t3.lua b/example/t3.lua index ec7cb6a..51b405d 100644 --- a/example/t3.lua +++ b/example/t3.lua @@ -1,7 +1,7 @@ --Copyright (c) 2011-2015 Zhihua Zhang (alacner@gmail.com) --ngx.set_header('Location', "http://www.google.com"); ---ngx.set_cookie('love', '123456') -- name, value, expire, path, domain, secure ---ngx.set_cookie('aa', 'ssssss') -- name, value, expire, path, domain, secure +--ngx.set_cookie('love', '123456') -- name, value, expire, path, domain, secure +--ngx.set_cookie('aa', 'ssssss') -- name, value, expire, path, domain, secure print = ngx.print local kit = require("kit") local print_r = kit.print_r @@ -31,10 +31,10 @@ local f = io.open('/root/480x480.png', 'rb') f:close() --ngx.print(ngx.set_cookie) local t = os.time() -ngx.set_cookie('love1', "me") -- name, value, expire, path, domain, secure ---ngx.set_cookie('love2', "me", 100) -- name, value, expire, path, domain, secure ---ngx.set_cookie('love3', '123456') -- name, value, expire, path, domain, secure ---ngx.set_cookie('isopen', 'true', 1000, '/', '192.168.137.126') -- name, value, expire, path, domain, secure +ngx.set_cookie('love1', "me") -- name, value, expire, path, domain, secure +--ngx.set_cookie('love2', "me", 100) -- name, value, expire, path, domain, secure +--ngx.set_cookie('love3', '123456') -- name, value, expire, path, domain, secure +--ngx.set_cookie('isopen', 'true', 1000, '/', '192.168.137.126') -- name, value, expire, path, domain, secure ngx.set_header('X-Memc-Flags', "11111111111111"); ngx.set_header('X-Memc-Flags', "2222222222222222222222222"); ngx.set_header('X-Memc-Flags', "f1111122222222333333334444445"); diff --git a/src/ngx_http_lua_module.c b/src/ngx_http_lua_module.c index 828b197..2970032 100644 --- a/src/ngx_http_lua_module.c +++ b/src/ngx_http_lua_module.c @@ -16,7 +16,7 @@ #include "lauxlib.h" #include "lualib.h" -#define safe_emalloc(nmemb, size, offset) malloc((nmemb) * (size) + (offset)) +#define safe_emalloc(nmemb, size, offset) malloc((nmemb) * (size) + (offset)) typedef struct { @@ -520,22 +520,22 @@ luaF_ngx_set_cookie (lua_State *L) lua_pushfstring(L, "; expires=%s", p); cnt++; } - + if (path != NULL) { lua_pushfstring(L, "; path=%s", path); cnt++; } - + if (domain != NULL) { lua_pushfstring(L, "; domain=%s", domain); cnt++; } - + if (secure) { lua_pushfstring(L, "; secure"); cnt++; } - + if (http_only) { lua_pushfstring(L, "; HttpOnly"); cnt++; @@ -625,7 +625,7 @@ static ngx_int_t ngx_set_http_out_header(ngx_http_request_t *r, char *key, char if (strcasecmp("Content-Type", key) == 0) { /* if key: content-type */ len = ngx_strlen(value); - r->headers_out.content_type_len = len; + r->headers_out.content_type_len = len; r->headers_out.content_type.len = len; r->headers_out.content_type.data = (u_char *)value; r->headers_out.content_type_lowcase = NULL; diff --git a/src/strtok_r.c b/src/strtok_r.c index 7519fd1..2219baa 100644 --- a/src/strtok_r.c +++ b/src/strtok_r.c @@ -13,11 +13,11 @@ * * 1. Redistributions of source code must retain the above copyright * notices, this list of conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright * notices, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * + * * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: *