Skip to content

Commit 47ebda8

Browse files
committed
Merge branch 'iresty-feature/fix_style'
2 parents 254720e + d4ef41b commit 47ebda8

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

lib/resty/http.lua

+8-9
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ local str_lower = string.lower
1010
local str_upper = string.upper
1111
local str_find = string.find
1212
local str_sub = string.sub
13-
local str_gsub = string.gsub
1413
local tbl_concat = table.concat
1514
local tbl_insert = table.insert
1615
local ngx_encode_args = ngx.encode_args
@@ -20,7 +19,6 @@ local ngx_re_find = ngx.re.find
2019
local ngx_log = ngx.log
2120
local ngx_DEBUG = ngx.DEBUG
2221
local ngx_ERR = ngx.ERR
23-
local ngx_NOTICE = ngx.NOTICE
2422
local ngx_var = ngx.var
2523
local ngx_print = ngx.print
2624
local co_yield = coroutine.yield
@@ -312,9 +310,9 @@ end
312310

313311
local function _chunked_body_reader(sock, default_chunk_size)
314312
return co_wrap(function(max_chunk_size)
315-
local max_chunk_size = max_chunk_size or default_chunk_size
316313
local remaining = 0
317314
local length
315+
max_chunk_size = max_chunk_size or default_chunk_size
318316

319317
repeat
320318
-- If we still have data on this chunk
@@ -374,15 +372,15 @@ end
374372

375373
local function _body_reader(sock, content_length, default_chunk_size)
376374
return co_wrap(function(max_chunk_size)
377-
local max_chunk_size = max_chunk_size or default_chunk_size
375+
max_chunk_size = max_chunk_size or default_chunk_size
378376

379377
if not content_length and max_chunk_size then
380378
-- We have no length, but wish to stream.
381379
-- HTTP 1.0 with no length will close connection, so read chunks to the end.
382380
repeat
383381
local str, err, partial = sock:receive(max_chunk_size)
384382
if not str and err == "closed" then
385-
max_chunk_size = tonumber(co_yield(partial, err) or default_chunk_size)
383+
co_yield(partial, err)
386384
end
387385

388386
max_chunk_size = tonumber(co_yield(str) or default_chunk_size)
@@ -416,7 +414,7 @@ local function _body_reader(sock, content_length, default_chunk_size)
416414
if length > 0 then
417415
local str, err = sock:receive(length)
418416
if not str then
419-
max_chunk_size = tonumber(co_yield(nil, err) or default_chunk_size)
417+
co_yield(nil, err)
420418
end
421419
received = received + length
422420

@@ -492,7 +490,7 @@ local function _send_body(sock, body)
492490
local chunk, err, partial = body()
493491

494492
if chunk then
495-
local ok,err = sock:send(chunk)
493+
local ok, err = sock:send(chunk)
496494

497495
if not ok then
498496
return nil, err
@@ -697,7 +695,7 @@ end
697695

698696

699697
function _M.request_pipeline(self, requests)
700-
for i, params in ipairs(requests) do
698+
for _, params in ipairs(requests) do
701699
if params.headers and params.headers["Expect"] == "100-continue" then
702700
return nil, "Cannot pipeline request specifying Expect: 100-continue"
703701
end
@@ -787,7 +785,8 @@ end
787785

788786

789787
function _M.get_client_body_reader(self, chunksize, sock)
790-
local chunksize = chunksize or 65536
788+
chunksize = chunksize or 65536
789+
791790
if not sock then
792791
local ok, err
793792
ok, sock, err = pcall(ngx_req_socket)

0 commit comments

Comments
 (0)