@@ -10,7 +10,6 @@ local str_lower = string.lower
10
10
local str_upper = string.upper
11
11
local str_find = string.find
12
12
local str_sub = string.sub
13
- local str_gsub = string.gsub
14
13
local tbl_concat = table.concat
15
14
local tbl_insert = table.insert
16
15
local ngx_encode_args = ngx .encode_args
@@ -20,7 +19,6 @@ local ngx_re_find = ngx.re.find
20
19
local ngx_log = ngx .log
21
20
local ngx_DEBUG = ngx .DEBUG
22
21
local ngx_ERR = ngx .ERR
23
- local ngx_NOTICE = ngx .NOTICE
24
22
local ngx_var = ngx .var
25
23
local ngx_print = ngx .print
26
24
local co_yield = coroutine.yield
312
310
313
311
local function _chunked_body_reader (sock , default_chunk_size )
314
312
return co_wrap (function (max_chunk_size )
315
- local max_chunk_size = max_chunk_size or default_chunk_size
316
313
local remaining = 0
317
314
local length
315
+ max_chunk_size = max_chunk_size or default_chunk_size
318
316
319
317
repeat
320
318
-- If we still have data on this chunk
@@ -374,15 +372,15 @@ end
374
372
375
373
local function _body_reader (sock , content_length , default_chunk_size )
376
374
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
378
376
379
377
if not content_length and max_chunk_size then
380
378
-- We have no length, but wish to stream.
381
379
-- HTTP 1.0 with no length will close connection, so read chunks to the end.
382
380
repeat
383
381
local str , err , partial = sock :receive (max_chunk_size )
384
382
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 )
386
384
end
387
385
388
386
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)
416
414
if length > 0 then
417
415
local str , err = sock :receive (length )
418
416
if not str then
419
- max_chunk_size = tonumber ( co_yield (nil , err ) or default_chunk_size )
417
+ co_yield (nil , err )
420
418
end
421
419
received = received + length
422
420
@@ -492,7 +490,7 @@ local function _send_body(sock, body)
492
490
local chunk , err , partial = body ()
493
491
494
492
if chunk then
495
- local ok ,err = sock :send (chunk )
493
+ local ok , err = sock :send (chunk )
496
494
497
495
if not ok then
498
496
return nil , err
697
695
698
696
699
697
function _M .request_pipeline (self , requests )
700
- for i , params in ipairs (requests ) do
698
+ for _ , params in ipairs (requests ) do
701
699
if params .headers and params .headers [" Expect" ] == " 100-continue" then
702
700
return nil , " Cannot pipeline request specifying Expect: 100-continue"
703
701
end
787
785
788
786
789
787
function _M .get_client_body_reader (self , chunksize , sock )
790
- local chunksize = chunksize or 65536
788
+ chunksize = chunksize or 65536
789
+
791
790
if not sock then
792
791
local ok , err
793
792
ok , sock , err = pcall (ngx_req_socket )
0 commit comments