Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit dc50543

Browse files
committed
major bug fix for --keep-alive option in multithreading mode (that 'shitty' _headers = {} made a one shared object for all connection objects)
1 parent 36ef8ca commit dc50543

2 files changed

Lines changed: 3 additions & 6 deletions

File tree

extra/keepalive/keepalive.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -295,10 +295,10 @@ def readlines(self, sizehint = 0):
295295
class HTTPConnection(httplib.HTTPConnection):
296296
# use the modified response class
297297
response_class = HTTPResponse
298-
_headers = {}
298+
_headers = None
299299

300300
def clearheaders(self):
301-
self._headers.clear()
301+
self._headers = {}
302302

303303
def putheader(self, header, value):
304304
"""Send a request header line to the server.

lib/request/connect.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -347,10 +347,7 @@ def queryPage(value=None, place=None, content=False, getSeqMatcher=False, silent
347347
if kb.nullConnection == "HEAD":
348348
pageLength = int(headers['Content-Length'])
349349
elif kb.nullConnection == "Range":
350-
if 'Content-Range' in headers:
351-
pageLength = int(headers['Content-Range'][headers['Content-Range'].find('/') + 1:])
352-
elif 'content-length' in headers: #sometimes
353-
pageLength = int(headers['content-length'])
350+
pageLength = int(headers['Content-Range'][headers['Content-Range'].find('/') + 1:])
354351

355352
if not pageLength:
356353
page, headers = Connect.getPage(url=uri, get=get, post=post, cookie=cookie, ua=ua, silent=silent, method=method, auxHeaders=auxHeaders, response=response, raise404=raise404)

0 commit comments

Comments
 (0)