more log + increase upload timeout
This commit is contained in:
+8
-48
@@ -89,8 +89,6 @@ local gmkerl_format = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
local function _rev_headers(sock)
|
local function _rev_headers(sock)
|
||||||
-- return headers, err
|
-- return headers, err
|
||||||
local headers = {}
|
local headers = {}
|
||||||
@@ -116,8 +114,6 @@ local function _rev_headers(sock)
|
|||||||
return headers
|
return headers
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
local function _receive_length(sock, length)
|
local function _receive_length(sock, length)
|
||||||
-- return chunk, err
|
-- return chunk, err
|
||||||
local chunk, err = sock:receive(length)
|
local chunk, err = sock:receive(length)
|
||||||
@@ -128,8 +124,6 @@ local function _receive_length(sock, length)
|
|||||||
return chunk
|
return chunk
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
local function _receive_chunked(sock, maxsize)
|
local function _receive_chunked(sock, maxsize)
|
||||||
-- return chunks, err
|
-- return chunks, err
|
||||||
local chunks = {}
|
local chunks = {}
|
||||||
@@ -171,8 +165,6 @@ local function _receive_chunked(sock, maxsize)
|
|||||||
return concat(chunks)
|
return concat(chunks)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
local function _receive(sock)
|
local function _receive(sock)
|
||||||
-- return {}, err
|
-- return {}, err
|
||||||
local line, err = sock:receive()
|
local line, err = sock:receive()
|
||||||
@@ -230,8 +222,6 @@ local function _receive(sock)
|
|||||||
return { status = status, headers = headers, body = body }
|
return { status = status, headers = headers, body = body }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
local function _req_header(method, path, headers, extra)
|
local function _req_header(method, path, headers, extra)
|
||||||
-- return req
|
-- return req
|
||||||
local req = {
|
local req = {
|
||||||
@@ -263,33 +253,34 @@ local function _req_header(method, path, headers, extra)
|
|||||||
return concat(req)
|
return concat(req)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
local function _request(sock, method, path, headers, body, extra)
|
local function _request(sock, method, path, headers, body, extra)
|
||||||
-- return {}, err
|
-- return {}, err
|
||||||
local host = headers.Host
|
local host = headers.Host
|
||||||
if not sock then
|
if not sock then
|
||||||
|
ngx.log(ngx.ERR, "sock not initialized yet")
|
||||||
return nil, "not initialized yet"
|
return nil, "not initialized yet"
|
||||||
else
|
else
|
||||||
print("Upyun module request connect host : ", host)
|
ngx.log(ngx.INFO, "Upyun module request connect host : ", host)
|
||||||
end
|
end
|
||||||
|
|
||||||
sock:settimeout(5000)
|
sock:settimeout(20000)
|
||||||
|
|
||||||
local ok, err = sock:connect(host, 80)
|
local ok, err = sock:connect(host, 80)
|
||||||
if not ok then
|
if not ok then
|
||||||
|
ngx.log(ngx.ERR, "sock:connect ERROR -> ", err)
|
||||||
return nil, err
|
return nil, err
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Build and send request header
|
-- Build and send request header
|
||||||
print("Debug upyun module request header method : ", method)
|
ngx.log(ngx.INFO, "Debug upyun module request header method : ", method)
|
||||||
print("Debug upyun module request header path : ", path)
|
ngx.log(ngx.INFO, "Debug upyun module request header path : ", path)
|
||||||
--print("Debug upyun module request header headers : ", headers)
|
--print("Debug upyun module request header headers : ", headers)
|
||||||
--print("Debug upyun module request header extra : ", extra)
|
--print("Debug upyun module request header extra : ", extra)
|
||||||
|
|
||||||
local header = _req_header(method, path, headers, extra)
|
local header = _req_header(method, path, headers, extra)
|
||||||
local bytes, err = sock:send(header)
|
local bytes, err = sock:send(header)
|
||||||
if not bytes then
|
if not bytes then
|
||||||
|
ngx.log(ngx.ERR, "sock:send ERR -> ", err)
|
||||||
return nil, err
|
return nil, err
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -297,6 +288,7 @@ local function _request(sock, method, path, headers, body, extra)
|
|||||||
if body and body.content then
|
if body and body.content then
|
||||||
local bytes, err = sock:send(body.content)
|
local bytes, err = sock:send(body.content)
|
||||||
if not bytes then
|
if not bytes then
|
||||||
|
ngx.log(ngx.ERR, "sock:send ERR -> ", err)
|
||||||
return nil, err
|
return nil, err
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -304,8 +296,6 @@ local function _request(sock, method, path, headers, body, extra)
|
|||||||
return _receive(sock)
|
return _receive(sock)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
local function _upyun_request(self, method, path, headers, body, extra)
|
local function _upyun_request(self, method, path, headers, body, extra)
|
||||||
local sock = self.sock
|
local sock = self.sock
|
||||||
local author_mode = self.author_mode
|
local author_mode = self.author_mode
|
||||||
@@ -323,15 +313,11 @@ local function _upyun_request(self, method, path, headers, body, extra)
|
|||||||
return _request(sock, method, path, headers, body, extra)
|
return _request(sock, method, path, headers, body, extra)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
local function _is_dir(path)
|
local function _is_dir(path)
|
||||||
-- return true or false
|
-- return true or false
|
||||||
return str_sub(path, -1, -1) == "/"
|
return str_sub(path, -1, -1) == "/"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
local function _parse_gmkerl(gmkerl, extra)
|
local function _parse_gmkerl(gmkerl, extra)
|
||||||
-- return ok, err
|
-- return ok, err
|
||||||
local expect_format = true
|
local expect_format = true
|
||||||
@@ -390,8 +376,6 @@ local function _parse_gmkerl(gmkerl, extra)
|
|||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
local function _format_path(path, legal_path)
|
local function _format_path(path, legal_path)
|
||||||
-- return path, err
|
-- return path, err
|
||||||
if not path or type(path) ~= "string" or path == "" then
|
if not path or type(path) ~= "string" or path == "" then
|
||||||
@@ -414,8 +398,6 @@ local function _format_path(path, legal_path)
|
|||||||
return path
|
return path
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
local function _parse_upyun_option(option, extra, content)
|
local function _parse_upyun_option(option, extra, content)
|
||||||
-- return modified extra
|
-- return modified extra
|
||||||
local mkdir = tostring(option.mkdir)
|
local mkdir = tostring(option.mkdir)
|
||||||
@@ -440,8 +422,6 @@ local function _parse_upyun_option(option, extra, content)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
local function _parse_upyun_headers(headers, regex)
|
local function _parse_upyun_headers(headers, regex)
|
||||||
-- return info, err
|
-- return info, err
|
||||||
if not headers or type(headers) ~= "table" then
|
if not headers or type(headers) ~= "table" then
|
||||||
@@ -464,8 +444,6 @@ local function _parse_upyun_headers(headers, regex)
|
|||||||
return info
|
return info
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
local function _parse_upyun_body(body)
|
local function _parse_upyun_body(body)
|
||||||
-- return info, err
|
-- return info, err
|
||||||
if not body or type(body) ~= "string" then
|
if not body or type(body) ~= "string" then
|
||||||
@@ -513,8 +491,6 @@ local function _parse_upyun_body(body)
|
|||||||
return info
|
return info
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function _M.new(self, config)
|
function _M.new(self, config)
|
||||||
local user = config.user
|
local user = config.user
|
||||||
local passwd = config.passwd
|
local passwd = config.passwd
|
||||||
@@ -596,8 +572,6 @@ function _M.new(self, config)
|
|||||||
}, mt)
|
}, mt)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function _M.upload_file(self, path, gmkerl, option)
|
function _M.upload_file(self, path, gmkerl, option)
|
||||||
-- return info, err
|
-- return info, err
|
||||||
local headers = self.headers
|
local headers = self.headers
|
||||||
@@ -654,8 +628,6 @@ function _M.upload_file(self, path, gmkerl, option)
|
|||||||
return ret
|
return ret
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function _M.download_file(self, path)
|
function _M.download_file(self, path)
|
||||||
-- return file, err
|
-- return file, err
|
||||||
local headers = self.headers
|
local headers = self.headers
|
||||||
@@ -678,8 +650,6 @@ function _M.download_file(self, path)
|
|||||||
return ret.body
|
return ret.body
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function _M.get_fileinfo(self, path)
|
function _M.get_fileinfo(self, path)
|
||||||
-- return info, err
|
-- return info, err
|
||||||
local headers = self.headers
|
local headers = self.headers
|
||||||
@@ -707,8 +677,6 @@ function _M.get_fileinfo(self, path)
|
|||||||
return ret
|
return ret
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function _M.remove_file(self, path)
|
function _M.remove_file(self, path)
|
||||||
-- return ok, err
|
-- return ok, err
|
||||||
local headers = self.headers
|
local headers = self.headers
|
||||||
@@ -731,8 +699,6 @@ function _M.remove_file(self, path)
|
|||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function _M.make_dir(self, path, option)
|
function _M.make_dir(self, path, option)
|
||||||
-- return ok, err
|
-- return ok, err
|
||||||
local headers = self.headers
|
local headers = self.headers
|
||||||
@@ -760,8 +726,6 @@ function _M.make_dir(self, path, option)
|
|||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function _M.read_dir(self, path)
|
function _M.read_dir(self, path)
|
||||||
-- return items, err
|
-- return items, err
|
||||||
local headers = self.headers
|
local headers = self.headers
|
||||||
@@ -789,8 +753,6 @@ function _M.read_dir(self, path)
|
|||||||
return ret
|
return ret
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function _M.get_usage(self, path)
|
function _M.get_usage(self, path)
|
||||||
-- return usage, err
|
-- return usage, err
|
||||||
local headers = self.headers
|
local headers = self.headers
|
||||||
@@ -815,6 +777,4 @@ function _M.get_usage(self, path)
|
|||||||
return ret.body
|
return ret.body
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return _M
|
return _M
|
||||||
Reference in New Issue
Block a user