Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions patator.py
Original file line number Diff line number Diff line change
Expand Up @@ -3629,9 +3629,6 @@ def execute(self, url=None, host=None, port='', scheme='http', path='/', params=
fp.setopt(pycurl.PROXYTYPE, proxy_type)
fp.setopt(pycurl.RESOLVE, [resolve])

def noop(buf): pass
fp.setopt(pycurl.WRITEFUNCTION, noop)

def debug_func(t, s):
if max_mem > 0 and trace.tell() > max_mem:
return 0
Expand All @@ -3644,12 +3641,13 @@ def debug_func(t, s):
elif t == pycurl.INFOTYPE_TEXT and 'upload completely sent off' in s:
trace.write('\n\n')

elif t in (pycurl.INFOTYPE_HEADER_IN, pycurl.INFOTYPE_DATA_IN):
elif t == pycurl.INFOTYPE_HEADER_IN:
trace.write(s)
response.write(s)

max_mem = int(max_mem)
response, trace = StringIO(), StringIO()
response, trace, tmpbuf = StringIO(), StringIO(), StringIO()

fp.setopt(pycurl.WRITEDATA, tmpbuf)

fp.setopt(pycurl.DEBUGFUNCTION, debug_func)
fp.setopt(pycurl.VERBOSE, 1)
Expand Down Expand Up @@ -3691,10 +3689,17 @@ def perform_fp(fp, method, url, header='', body=''):
else:
fp.setopt(pycurl.CUSTOMREQUEST, method)

match = re.search(r'Accept-Encoding:(.+)', header, re.IGNORECASE)
if match != None:
fp.setopt(pycurl.ACCEPT_ENCODING, match.groups()[0].rstrip())
headers = [h.strip('\r') for h in header.split('\n') if h]
fp.setopt(pycurl.HTTPHEADER, headers)

fp.perform()
response.write(tmpbuf.getvalue())
trace.write(tmpbuf.getvalue()[tmpbuf.getvalue().find('\r\n\r\n') + 4:])
tmpbuf.truncate(0)
tmpbuf.seek(0)

if before_urls:
for before_url in before_urls.split(','):
Expand Down