@@ -6,7 +6,6 @@ local ngx_req = ngx.req
6
6
local ngx_req_socket = ngx_req .socket
7
7
local ngx_req_get_headers = ngx_req .get_headers
8
8
local ngx_req_get_method = ngx_req .get_method
9
- local str_gmatch = string.gmatch
10
9
local str_lower = string.lower
11
10
local str_upper = string.upper
12
11
local str_find = string.find
@@ -112,14 +111,15 @@ local HTTP = {
112
111
[1.1 ] = " HTTP/1.1\r\n " ,
113
112
}
114
113
114
+
115
115
local DEFAULT_PARAMS = {
116
116
method = " GET" ,
117
117
path = " /" ,
118
118
version = 1.1 ,
119
119
}
120
120
121
121
122
- function _M .new (self )
122
+ function _M .new (_ )
123
123
local sock , err = ngx_socket_tcp ()
124
124
if not sock then
125
125
return nil , err
@@ -230,7 +230,7 @@ local function _should_receive_body(method, code)
230
230
end
231
231
232
232
233
- function _M .parse_uri (self , uri , query_in_path )
233
+ function _M .parse_uri (_ , uri , query_in_path )
234
234
if query_in_path == nil then query_in_path = true end
235
235
236
236
local m , err = ngx_re_match (uri , [[ ^(?:(http[s]?):)?//([^:/\?]+)(?::(\d+))?([^\?]*)\??(.*)]] , " jo" )
@@ -339,6 +339,8 @@ local function _receive_headers(sock)
339
339
end
340
340
341
341
local m , err = ngx_re_match (line , " ([^:\\ s]+):\\ s*(.*)" , " jo" )
342
+ if err then ngx_log (ngx_ERR , err ) end
343
+
342
344
if not m then
343
345
break
344
346
end
563
565
564
566
565
567
local function _handle_continue (sock , body )
566
- local status , version , reason , err = _receive_status (sock )
568
+ local status , version , reason , err = _receive_status (sock ) -- luacheck: no unused
567
569
if not status then
568
570
return nil , nil , err
569
571
end
@@ -662,7 +664,7 @@ function _M.read_response(self, params)
662
664
if not _status then
663
665
return nil , _err
664
666
elseif _status ~= 100 then
665
- status , version , err = _status , _version , _err
667
+ status , version , err = _status , _version , _err -- luacheck: no unused
666
668
end
667
669
end
668
670
@@ -789,6 +791,7 @@ function _M.request_pipeline(self, requests)
789
791
return responses
790
792
end
791
793
794
+
792
795
function _M .request_uri (self , uri , params )
793
796
params = tbl_copy (params or {}) -- Take by value
794
797
@@ -891,7 +894,7 @@ function _M.request_uri(self, uri, params)
891
894
end
892
895
893
896
894
- function _M .get_client_body_reader (self , chunksize , sock )
897
+ function _M .get_client_body_reader (_ , chunksize , sock )
895
898
chunksize = chunksize or 65536
896
899
897
900
if not sock then
@@ -935,7 +938,7 @@ function _M.proxy_request(self, chunksize)
935
938
end
936
939
937
940
938
- function _M .proxy_response (self , response , chunksize )
941
+ function _M .proxy_response (_ , response , chunksize )
939
942
if not response then
940
943
ngx_log (ngx_ERR , " no response provided" )
941
944
return
@@ -968,10 +971,12 @@ function _M.proxy_response(self, response, chunksize)
968
971
until not chunk
969
972
end
970
973
974
+
971
975
function _M .set_proxy_options (self , opts )
972
976
self .proxy_opts = tbl_copy (opts ) -- Take by value
973
977
end
974
978
979
+
975
980
function _M .get_proxy_uri (self , scheme , host )
976
981
if not self .proxy_opts then
977
982
return nil
@@ -1070,4 +1075,5 @@ function _M.connect_proxy(self, proxy_uri, scheme, host, port)
1070
1075
return c , nil
1071
1076
end
1072
1077
1078
+
1073
1079
return _M
0 commit comments