Debugging response saving: save page even if it's an HTTP error
This will help debug new types of exit node blockage or other errors. Signed-off-by: Jesús <heckyel@hyperbola.info>
This commit is contained in:
parent
07f14343c4
commit
d604a007a9
@ -292,6 +292,15 @@ def fetch_url(url, headers=(), timeout=15, report_text=None, data=None,
|
|||||||
content,
|
content,
|
||||||
response.getheader('Content-Encoding', default='identity'))
|
response.getheader('Content-Encoding', default='identity'))
|
||||||
|
|
||||||
|
if (settings.debugging_save_responses
|
||||||
|
and debug_name is not None and content):
|
||||||
|
save_dir = os.path.join(settings.data_dir, 'debug')
|
||||||
|
if not os.path.exists(save_dir):
|
||||||
|
os.makedirs(save_dir)
|
||||||
|
|
||||||
|
with open(os.path.join(save_dir, debug_name), 'wb') as f:
|
||||||
|
f.write(content)
|
||||||
|
|
||||||
if response.status == 429:
|
if response.status == 429:
|
||||||
ip = re.search(
|
ip = re.search(
|
||||||
br'IP address: ((?:[\da-f]*:)+[\da-f]+|(?:\d+\.)+\d+)',
|
br'IP address: ((?:[\da-f]*:)+[\da-f]+|(?:\d+\.)+\d+)',
|
||||||
@ -321,14 +330,6 @@ def fetch_url(url, headers=(), timeout=15, report_text=None, data=None,
|
|||||||
if report_text:
|
if report_text:
|
||||||
print(report_text, ' Latency:', round(response_time - start_time, 3), ' Read time:', round(read_finish - response_time,3))
|
print(report_text, ' Latency:', round(response_time - start_time, 3), ' Read time:', round(read_finish - response_time,3))
|
||||||
|
|
||||||
if settings.debugging_save_responses and debug_name is not None:
|
|
||||||
save_dir = os.path.join(settings.data_dir, 'debug')
|
|
||||||
if not os.path.exists(save_dir):
|
|
||||||
os.makedirs(save_dir)
|
|
||||||
|
|
||||||
with open(os.path.join(save_dir, debug_name), 'wb') as f:
|
|
||||||
f.write(content)
|
|
||||||
|
|
||||||
return content
|
return content
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user