File tree 1 file changed +10
-3
lines changed
1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -288,17 +288,24 @@ def _readinto(self, buf: bytearray) -> int:
288
288
self ._parse_headers ()
289
289
return 0
290
290
self ._remaining = http_chunk_size
291
+ elif self ._remaining is None :
292
+ # the Content-Length is not provided in the HTTP header
293
+ # so try parsing as long as their is data in the socket
294
+ pass
291
295
else :
292
296
return 0
293
297
294
298
nbytes = len (buf )
295
- if nbytes > self ._remaining :
296
- nbytes = self ._remaining
299
+ if self ._remaining and nbytes > self ._remaining :
300
+ # if Content-Length was provided and remaining bytes larges than buffer
301
+ nbytes = self ._remaining # adjust read amount
297
302
298
303
read = self ._read_from_buffer (buf , nbytes )
299
304
if read == 0 :
300
305
read = self ._recv_into (buf , nbytes )
301
- self ._remaining -= read
306
+ if self ._remaining :
307
+ # if Content-Length was provided, adjust the remaining amount to still read
308
+ self ._remaining -= read
302
309
303
310
return read
304
311
You can’t perform that action at this time.
0 commit comments