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