comparison roundup/scripts/roundup_server.py @ 8256:3a04ff6f1004

fix: crash when logging ip if roundup-server times out Under some conditions (seen in production, no reproducer), if connection timed out, there is no headers attribute RoundupRequestHandler. Check for headers attr before accessing self.headers.
author John Rouillard <rouilj@ieee.org>
date Wed, 01 Jan 2025 17:51:05 -0500
parents 4ed886dc2558
children 341841a9edc5
comparison
equal deleted inserted replaced
8255:7d72b9a9fe9c 8256:3a04ff6f1004
540 client ip address otherwise. 540 client ip address otherwise.
541 if returned string is from X-Forwarded-For append + to string. 541 if returned string is from X-Forwarded-For append + to string.
542 """ 542 """
543 from_forwarded_header="" 543 from_forwarded_header=""
544 forwarded_for = None 544 forwarded_for = None
545 if 'X-FORWARDED-FOR' in self.headers: 545
546 # if connection timed out, there is no headers property
547 if hasattr(self, 'headers') and ('X-FORWARDED-FOR' in self.headers):
546 forwarded_for = re.split(r'[,\s]', 548 forwarded_for = re.split(r'[,\s]',
547 self.headers['X-FORWARDED-FOR'], 549 self.headers['X-FORWARDED-FOR'],
548 maxsplit=1)[0] 550 maxsplit=1)[0]
549 from_forwarded_header="+" 551 from_forwarded_header="+"
550 if self.LOG_IPADDRESS: 552 if self.LOG_IPADDRESS:

Roundup Issue Tracker: http://roundup-tracker.org/