update '--write-pages' (#737)
- fix infinite recursion for responses with multiple entries in 'history' - hide values of Set-Cookie headers - only write the response content by default (use '-o write-pages=all' to also include HTTP headers)
This commit is contained in:
@@ -328,14 +328,15 @@ class Extractor():
|
||||
test = (test, None)
|
||||
yield test
|
||||
|
||||
def _dump_response(self, response):
|
||||
def _dump_response(self, response, history=True):
|
||||
"""Write the response content to a .dump file in the current directory.
|
||||
|
||||
The file name is derived from the response url,
|
||||
replacing special characters with "_"
|
||||
"""
|
||||
for resp in response.history:
|
||||
self._dump_response(resp)
|
||||
if history:
|
||||
for resp in response.history:
|
||||
self._dump_response(resp, False)
|
||||
|
||||
if hasattr(Extractor, "_dump_index"):
|
||||
Extractor._dump_index += 1
|
||||
@@ -350,7 +351,8 @@ class Extractor():
|
||||
|
||||
try:
|
||||
with open(fname + ".dump", 'wb') as fp:
|
||||
util.dump_response(response, fp)
|
||||
util.dump_response(
|
||||
response, fp, headers=(self._write_pages == "all"))
|
||||
except Exception as e:
|
||||
self.log.warning("Failed to dump HTTP request (%s: %s)",
|
||||
e.__class__.__name__, e)
|
||||
|
||||
Reference in New Issue
Block a user