Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -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
16 changes: 8 additions & 8 deletions example/nginx/boundary.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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

--
Expand All @@ -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")
Expand All @@ -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

Expand Down
4 changes: 2 additions & 2 deletions example/nginx/urlcode.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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]]
Expand Down Expand Up @@ -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
8 changes: 4 additions & 4 deletions example/t1.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
12 changes: 6 additions & 6 deletions example/t3.lua
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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");
Expand Down
12 changes: 6 additions & 6 deletions src/ngx_http_lua_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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++;
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/strtok_r.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:
*
Expand Down