| 360 | | while True: |
|---|
| 361 | | req = self.RequestHandlerClass(self) |
|---|
| 362 | | # This order of operations should guarantee correct pipelining. |
|---|
| 363 | | req.parse_request() |
|---|
| 364 | | if not req.ready: |
|---|
| 365 | | break |
|---|
| 366 | | req.respond() |
|---|
| 367 | | if req.close_connection: |
|---|
| 368 | | break |
|---|
| | 360 | try: |
|---|
| | 361 | while True: |
|---|
| | 362 | # (re)set req to None so that if something goes wrong in |
|---|
| | 363 | # the RequestHandlerClass constructor, the error doesn't |
|---|
| | 364 | # get written to the previous request. |
|---|
| | 365 | req = None |
|---|
| | 366 | req = self.RequestHandlerClass(self) |
|---|
| | 367 | # This order of operations should guarantee correct pipelining. |
|---|
| | 368 | req.parse_request() |
|---|
| | 369 | if not req.ready: |
|---|
| | 370 | break |
|---|
| | 371 | req.respond() |
|---|
| | 372 | if req.close_connection: |
|---|
| | 373 | break |
|---|
| | 374 | except socket.error, e: |
|---|
| | 375 | errno = e.args[0] |
|---|
| | 376 | if errno not in socket_errors_to_ignore: |
|---|
| | 377 | if req: |
|---|
| | 378 | req.simple_response("500 Internal Server Error", |
|---|
| | 379 | traceback.format_exc()) |
|---|
| | 380 | except (KeyboardInterrupt, SystemExit): |
|---|
| | 381 | raise |
|---|
| | 382 | except: |
|---|
| | 383 | if req: |
|---|
| | 384 | req.simple_response("500 Internal Server Error", |
|---|
| | 385 | traceback.format_exc()) |
|---|