comparison roundup/scripts/roundup_server.py @ 8269:341841a9edc5

Handle timeout exception in roundup-server better. A timeout in roundup-server used to generate another exception: OSError: cannot read from timed out object when it tried to reuse the socket that timed out. Now return status 408, a brief message and trigger closing of the socket. Manual testing, no CI. To test used curl -X POST with no --data defined.
author John Rouillard <rouilj@ieee.org>
date Sun, 12 Jan 2025 12:59:41 -0500
parents 3a04ff6f1004
children 03513f5066f3
comparison
equal deleted inserted replaced
8268:05d8806b25ad 8269:341841a9edc5
280 self.send_error(403, '%s (%s)' % (self.path, message)) 280 self.send_error(403, '%s (%s)' % (self.path, message))
281 except Exception: 281 except Exception:
282 exc, val, tb = sys.exc_info() 282 exc, val, tb = sys.exc_info()
283 if hasattr(socket, 'timeout') and isinstance(val, socket.timeout): 283 if hasattr(socket, 'timeout') and isinstance(val, socket.timeout):
284 self.log_error('timeout') 284 self.log_error('timeout')
285 self.send_response(408)
286 self.send_header('Content-Type', 'text/html')
287
288 output = s2b('''<body><p>Connection timed out</p></body>''')
289 # Close connection
290 self.send_header('Content-Length', len(output))
291 self.end_headers()
292 self.wfile.write(output)
293 self.close_connection = True
285 else: 294 else:
286 self.send_response(400) 295 self.send_response(400)
287 self.send_header('Content-Type', 'text/html') 296 self.send_header('Content-Type', 'text/html')
288 if self.DEBUG_MODE: 297 if self.DEBUG_MODE:
289 try: 298 try:

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