We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Include request URL in error message
It would be really helpful if the logged error message were "Error handling request http://host/path/etc" instead of just "Error handling request".


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `gunicorn/workers/base.py`
Content:
```
1 # -*- coding: utf-8 -
2 #
3 # This file is part of gunicorn released under the MIT license.
4 # See the NOTICE for more information.
5 
6 from datetime import datetime
7 import os
8 import signal
9 import sys
10 import time
11 import traceback
12 from random import randint
13 
14 
15 from gunicorn import util
16 from gunicorn.workers.workertmp import WorkerTmp
17 from gunicorn.reloader import Reloader
18 from gunicorn.http.errors import (
19     InvalidHeader, InvalidHeaderName, InvalidRequestLine, InvalidRequestMethod,
20     InvalidHTTPVersion, LimitRequestLine, LimitRequestHeaders,
21 )
22 from gunicorn.http.errors import InvalidProxyLine, ForbiddenProxyRequest
23 from gunicorn.http.wsgi import default_environ, Response
24 from gunicorn.six import MAXSIZE
25 
26 
27 class Worker(object):
28 
29     SIGNALS = [getattr(signal, "SIG%s" % x)
30             for x in "ABRT HUP QUIT INT TERM USR1 USR2 WINCH CHLD".split()]
31 
32     PIPE = []
33 
34     def __init__(self, age, ppid, sockets, app, timeout, cfg, log):
35         """\
36         This is called pre-fork so it shouldn't do anything to the
37         current process. If there's a need to make process wide
38         changes you'll want to do that in ``self.init_process()``.
39         """
40         self.age = age
41         self.ppid = ppid
42         self.sockets = sockets
43         self.app = app
44         self.timeout = timeout
45         self.cfg = cfg
46         self.booted = False
47         self.aborted = False
48         self.reloader = None
49 
50         self.nr = 0
51         jitter = randint(0, cfg.max_requests_jitter)
52         self.max_requests = cfg.max_requests + jitter or MAXSIZE
53         self.alive = True
54         self.log = log
55         self.tmp = WorkerTmp(cfg)
56 
57     def __str__(self):
58         return "<Worker %s>" % self.pid
59 
60     @property
61     def pid(self):
62         return os.getpid()
63 
64     def notify(self):
65         """\
66         Your worker subclass must arrange to have this method called
67         once every ``self.timeout`` seconds. If you fail in accomplishing
68         this task, the master process will murder your workers.
69         """
70         self.tmp.notify()
71 
72     def run(self):
73         """\
74         This is the mainloop of a worker process. You should override
75         this method in a subclass to provide the intended behaviour
76         for your particular evil schemes.
77         """
78         raise NotImplementedError()
79 
80     def init_process(self):
81         """\
82         If you override this method in a subclass, the last statement
83         in the function should be to call this method with
84         super(MyWorkerClass, self).init_process() so that the ``run()``
85         loop is initiated.
86         """
87 
88         # start the reloader
89         if self.cfg.reload:
90             def changed(fname):
91                 self.log.info("Worker reloading: %s modified", fname)
92                 os.kill(self.pid, signal.SIGQUIT)
93             self.reloader = Reloader(callback=changed)
94             self.reloader.start()
95 
96         # set environment' variables
97         if self.cfg.env:
98             for k, v in self.cfg.env.items():
99                 os.environ[k] = v
100 
101         util.set_owner_process(self.cfg.uid, self.cfg.gid)
102 
103         # Reseed the random number generator
104         util.seed()
105 
106         # For waking ourselves up
107         self.PIPE = os.pipe()
108         for p in self.PIPE:
109             util.set_non_blocking(p)
110             util.close_on_exec(p)
111 
112         # Prevent fd inheritance
113         [util.close_on_exec(s) for s in self.sockets]
114         util.close_on_exec(self.tmp.fileno())
115 
116         self.log.close_on_exec()
117 
118         self.init_signals()
119 
120         self.cfg.post_worker_init(self)
121 
122         self.load_wsgi()
123 
124         # Enter main run loop
125         self.booted = True
126         self.run()
127 
128     def load_wsgi(self):
129         try:
130             self.wsgi = self.app.wsgi()
131         except SyntaxError as e:
132             if not self.cfg.reload:
133                 raise
134 
135             self.log.exception(e)
136 
137             exc_type, exc_val, exc_tb = sys.exc_info()
138             self.reloader.add_extra_file(exc_val.filename)
139 
140             tb_string = traceback.format_exc(exc_tb)
141             self.wsgi = util.make_fail_app(tb_string)
142 
143     def init_signals(self):
144         # reset signaling
145         [signal.signal(s, signal.SIG_DFL) for s in self.SIGNALS]
146         # init new signaling
147         signal.signal(signal.SIGQUIT, self.handle_quit)
148         signal.signal(signal.SIGTERM, self.handle_exit)
149         signal.signal(signal.SIGINT, self.handle_quit)
150         signal.signal(signal.SIGWINCH, self.handle_winch)
151         signal.signal(signal.SIGUSR1, self.handle_usr1)
152         signal.signal(signal.SIGABRT, self.handle_abort)
153 
154         # Don't let SIGTERM and SIGUSR1 disturb active requests
155         # by interrupting system calls
156         if hasattr(signal, 'siginterrupt'):  # python >= 2.6
157             signal.siginterrupt(signal.SIGTERM, False)
158             signal.siginterrupt(signal.SIGUSR1, False)
159 
160     def handle_usr1(self, sig, frame):
161         self.log.reopen_files()
162 
163     def handle_exit(self, sig, frame):
164         self.alive = False
165 
166     def handle_quit(self, sig, frame):
167         self.alive = False
168         # worker_int callback
169         self.cfg.worker_int(self)
170         time.sleep(0.1)
171         sys.exit(0)
172 
173     def handle_abort(self, sig, frame):
174         self.alive = False
175         self.cfg.worker_abort(self)
176         sys.exit(1)
177 
178     def handle_error(self, req, client, addr, exc):
179         request_start = datetime.now()
180         addr = addr or ('', -1)  # unix socket case
181         if isinstance(exc, (InvalidRequestLine, InvalidRequestMethod,
182                 InvalidHTTPVersion, InvalidHeader, InvalidHeaderName,
183                 LimitRequestLine, LimitRequestHeaders,
184                 InvalidProxyLine, ForbiddenProxyRequest)):
185 
186             status_int = 400
187             reason = "Bad Request"
188 
189             if isinstance(exc, InvalidRequestLine):
190                 mesg = "Invalid Request Line '%s'" % str(exc)
191             elif isinstance(exc, InvalidRequestMethod):
192                 mesg = "Invalid Method '%s'" % str(exc)
193             elif isinstance(exc, InvalidHTTPVersion):
194                 mesg = "Invalid HTTP Version '%s'" % str(exc)
195             elif isinstance(exc, (InvalidHeaderName, InvalidHeader,)):
196                 mesg = "%s" % str(exc)
197                 if not req and hasattr(exc, "req"):
198                     req = exc.req  # for access log
199             elif isinstance(exc, LimitRequestLine):
200                 mesg = "%s" % str(exc)
201             elif isinstance(exc, LimitRequestHeaders):
202                 mesg = "Error parsing headers: '%s'" % str(exc)
203             elif isinstance(exc, InvalidProxyLine):
204                 mesg = "'%s'" % str(exc)
205             elif isinstance(exc, ForbiddenProxyRequest):
206                 reason = "Forbidden"
207                 mesg = "Request forbidden"
208                 status_int = 403
209 
210             msg = "Invalid request from ip={ip}: {error}"
211             self.log.debug(msg.format(ip=addr[0], error=str(exc)))
212         else:
213             self.log.exception("Error handling request")
214 
215             status_int = 500
216             reason = "Internal Server Error"
217             mesg = ""
218 
219         if req is not None:
220             request_time = datetime.now() - request_start
221             environ = default_environ(req, client, self.cfg)
222             environ['REMOTE_ADDR'] = addr[0]
223             environ['REMOTE_PORT'] = str(addr[1])
224             resp = Response(req, client, self.cfg)
225             resp.status = "%s %s" % (status_int, reason)
226             resp.response_length = len(mesg)
227             self.log.access(resp, req, environ, request_time)
228 
229         try:
230             util.write_error(client, status_int, reason, mesg)
231         except:
232             self.log.debug("Failed to send error message.")
233 
234     def handle_winch(self, sig, fname):
235         # Ignore SIGWINCH in worker. Fixes a crash on OpenBSD.
236         return
237
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/gunicorn/workers/base.py b/gunicorn/workers/base.py
--- a/gunicorn/workers/base.py
+++ b/gunicorn/workers/base.py
@@ -210,7 +210,7 @@
             msg = "Invalid request from ip={ip}: {error}"
             self.log.debug(msg.format(ip=addr[0], error=str(exc)))
         else:
-            self.log.exception("Error handling request")
+            self.log.exception("Error handling request %s", req.uri)
 
             status_int = 500
             reason = "Internal Server Error"

{"golden_diff": "diff --git a/gunicorn/workers/base.py b/gunicorn/workers/base.py\n--- a/gunicorn/workers/base.py\n+++ b/gunicorn/workers/base.py\n@@ -210,7 +210,7 @@\n             msg = \"Invalid request from ip={ip}: {error}\"\n             self.log.debug(msg.format(ip=addr[0], error=str(exc)))\n         else:\n-            self.log.exception(\"Error handling request\")\n+            self.log.exception(\"Error handling request %s\", req.uri)\n \n             status_int = 500\n             reason = \"Internal Server Error\"\n", "issue": "Include request URL in error message\nIt would be really helpful if the logged error message were \"Error handling request http://host/path/etc\" instead of just \"Error handling request\".\n\n", "before_files": [{"content": "# -*- coding: utf-8 -\n#\n# This file is part of gunicorn released under the MIT license.\n# See the NOTICE for more information.\n\nfrom datetime import datetime\nimport os\nimport signal\nimport sys\nimport time\nimport traceback\nfrom random import randint\n\n\nfrom gunicorn import util\nfrom gunicorn.workers.workertmp import WorkerTmp\nfrom gunicorn.reloader import Reloader\nfrom gunicorn.http.errors import (\n    InvalidHeader, InvalidHeaderName, InvalidRequestLine, InvalidRequestMethod,\n    InvalidHTTPVersion, LimitRequestLine, LimitRequestHeaders,\n)\nfrom gunicorn.http.errors import InvalidProxyLine, ForbiddenProxyRequest\nfrom gunicorn.http.wsgi import default_environ, Response\nfrom gunicorn.six import MAXSIZE\n\n\nclass Worker(object):\n\n    SIGNALS = [getattr(signal, \"SIG%s\" % x)\n            for x in \"ABRT HUP QUIT INT TERM USR1 USR2 WINCH CHLD\".split()]\n\n    PIPE = []\n\n    def __init__(self, age, ppid, sockets, app, timeout, cfg, log):\n        \"\"\"\\\n        This is called pre-fork so it shouldn't do anything to the\n        current process. If there's a need to make process wide\n        changes you'll want to do that in ``self.init_process()``.\n        \"\"\"\n        self.age = age\n        self.ppid = ppid\n        self.sockets = sockets\n        self.app = app\n        self.timeout = timeout\n        self.cfg = cfg\n        self.booted = False\n        self.aborted = False\n        self.reloader = None\n\n        self.nr = 0\n        jitter = randint(0, cfg.max_requests_jitter)\n        self.max_requests = cfg.max_requests + jitter or MAXSIZE\n        self.alive = True\n        self.log = log\n        self.tmp = WorkerTmp(cfg)\n\n    def __str__(self):\n        return \"<Worker %s>\" % self.pid\n\n    @property\n    def pid(self):\n        return os.getpid()\n\n    def notify(self):\n        \"\"\"\\\n        Your worker subclass must arrange to have this method called\n        once every ``self.timeout`` seconds. If you fail in accomplishing\n        this task, the master process will murder your workers.\n        \"\"\"\n        self.tmp.notify()\n\n    def run(self):\n        \"\"\"\\\n        This is the mainloop of a worker process. You should override\n        this method in a subclass to provide the intended behaviour\n        for your particular evil schemes.\n        \"\"\"\n        raise NotImplementedError()\n\n    def init_process(self):\n        \"\"\"\\\n        If you override this method in a subclass, the last statement\n        in the function should be to call this method with\n        super(MyWorkerClass, self).init_process() so that the ``run()``\n        loop is initiated.\n        \"\"\"\n\n        # start the reloader\n        if self.cfg.reload:\n            def changed(fname):\n                self.log.info(\"Worker reloading: %s modified\", fname)\n                os.kill(self.pid, signal.SIGQUIT)\n            self.reloader = Reloader(callback=changed)\n            self.reloader.start()\n\n        # set environment' variables\n        if self.cfg.env:\n            for k, v in self.cfg.env.items():\n                os.environ[k] = v\n\n        util.set_owner_process(self.cfg.uid, self.cfg.gid)\n\n        # Reseed the random number generator\n        util.seed()\n\n        # For waking ourselves up\n        self.PIPE = os.pipe()\n        for p in self.PIPE:\n            util.set_non_blocking(p)\n            util.close_on_exec(p)\n\n        # Prevent fd inheritance\n        [util.close_on_exec(s) for s in self.sockets]\n        util.close_on_exec(self.tmp.fileno())\n\n        self.log.close_on_exec()\n\n        self.init_signals()\n\n        self.cfg.post_worker_init(self)\n\n        self.load_wsgi()\n\n        # Enter main run loop\n        self.booted = True\n        self.run()\n\n    def load_wsgi(self):\n        try:\n            self.wsgi = self.app.wsgi()\n        except SyntaxError as e:\n            if not self.cfg.reload:\n                raise\n\n            self.log.exception(e)\n\n            exc_type, exc_val, exc_tb = sys.exc_info()\n            self.reloader.add_extra_file(exc_val.filename)\n\n            tb_string = traceback.format_exc(exc_tb)\n            self.wsgi = util.make_fail_app(tb_string)\n\n    def init_signals(self):\n        # reset signaling\n        [signal.signal(s, signal.SIG_DFL) for s in self.SIGNALS]\n        # init new signaling\n        signal.signal(signal.SIGQUIT, self.handle_quit)\n        signal.signal(signal.SIGTERM, self.handle_exit)\n        signal.signal(signal.SIGINT, self.handle_quit)\n        signal.signal(signal.SIGWINCH, self.handle_winch)\n        signal.signal(signal.SIGUSR1, self.handle_usr1)\n        signal.signal(signal.SIGABRT, self.handle_abort)\n\n        # Don't let SIGTERM and SIGUSR1 disturb active requests\n        # by interrupting system calls\n        if hasattr(signal, 'siginterrupt'):  # python >= 2.6\n            signal.siginterrupt(signal.SIGTERM, False)\n            signal.siginterrupt(signal.SIGUSR1, False)\n\n    def handle_usr1(self, sig, frame):\n        self.log.reopen_files()\n\n    def handle_exit(self, sig, frame):\n        self.alive = False\n\n    def handle_quit(self, sig, frame):\n        self.alive = False\n        # worker_int callback\n        self.cfg.worker_int(self)\n        time.sleep(0.1)\n        sys.exit(0)\n\n    def handle_abort(self, sig, frame):\n        self.alive = False\n        self.cfg.worker_abort(self)\n        sys.exit(1)\n\n    def handle_error(self, req, client, addr, exc):\n        request_start = datetime.now()\n        addr = addr or ('', -1)  # unix socket case\n        if isinstance(exc, (InvalidRequestLine, InvalidRequestMethod,\n                InvalidHTTPVersion, InvalidHeader, InvalidHeaderName,\n                LimitRequestLine, LimitRequestHeaders,\n                InvalidProxyLine, ForbiddenProxyRequest)):\n\n            status_int = 400\n            reason = \"Bad Request\"\n\n            if isinstance(exc, InvalidRequestLine):\n                mesg = \"Invalid Request Line '%s'\" % str(exc)\n            elif isinstance(exc, InvalidRequestMethod):\n                mesg = \"Invalid Method '%s'\" % str(exc)\n            elif isinstance(exc, InvalidHTTPVersion):\n                mesg = \"Invalid HTTP Version '%s'\" % str(exc)\n            elif isinstance(exc, (InvalidHeaderName, InvalidHeader,)):\n                mesg = \"%s\" % str(exc)\n                if not req and hasattr(exc, \"req\"):\n                    req = exc.req  # for access log\n            elif isinstance(exc, LimitRequestLine):\n                mesg = \"%s\" % str(exc)\n            elif isinstance(exc, LimitRequestHeaders):\n                mesg = \"Error parsing headers: '%s'\" % str(exc)\n            elif isinstance(exc, InvalidProxyLine):\n                mesg = \"'%s'\" % str(exc)\n            elif isinstance(exc, ForbiddenProxyRequest):\n                reason = \"Forbidden\"\n                mesg = \"Request forbidden\"\n                status_int = 403\n\n            msg = \"Invalid request from ip={ip}: {error}\"\n            self.log.debug(msg.format(ip=addr[0], error=str(exc)))\n        else:\n            self.log.exception(\"Error handling request\")\n\n            status_int = 500\n            reason = \"Internal Server Error\"\n            mesg = \"\"\n\n        if req is not None:\n            request_time = datetime.now() - request_start\n            environ = default_environ(req, client, self.cfg)\n            environ['REMOTE_ADDR'] = addr[0]\n            environ['REMOTE_PORT'] = str(addr[1])\n            resp = Response(req, client, self.cfg)\n            resp.status = \"%s %s\" % (status_int, reason)\n            resp.response_length = len(mesg)\n            self.log.access(resp, req, environ, request_time)\n\n        try:\n            util.write_error(client, status_int, reason, mesg)\n        except:\n            self.log.debug(\"Failed to send error message.\")\n\n    def handle_winch(self, sig, fname):\n        # Ignore SIGWINCH in worker. Fixes a crash on OpenBSD.\n        return\n", "path": "gunicorn/workers/base.py"}], "after_files": [{"content": "# -*- coding: utf-8 -\n#\n# This file is part of gunicorn released under the MIT license.\n# See the NOTICE for more information.\n\nfrom datetime import datetime\nimport os\nimport signal\nimport sys\nimport time\nimport traceback\nfrom random import randint\n\n\nfrom gunicorn import util\nfrom gunicorn.workers.workertmp import WorkerTmp\nfrom gunicorn.reloader import Reloader\nfrom gunicorn.http.errors import (\n    InvalidHeader, InvalidHeaderName, InvalidRequestLine, InvalidRequestMethod,\n    InvalidHTTPVersion, LimitRequestLine, LimitRequestHeaders,\n)\nfrom gunicorn.http.errors import InvalidProxyLine, ForbiddenProxyRequest\nfrom gunicorn.http.wsgi import default_environ, Response\nfrom gunicorn.six import MAXSIZE\n\n\nclass Worker(object):\n\n    SIGNALS = [getattr(signal, \"SIG%s\" % x)\n            for x in \"ABRT HUP QUIT INT TERM USR1 USR2 WINCH CHLD\".split()]\n\n    PIPE = []\n\n    def __init__(self, age, ppid, sockets, app, timeout, cfg, log):\n        \"\"\"\\\n        This is called pre-fork so it shouldn't do anything to the\n        current process. If there's a need to make process wide\n        changes you'll want to do that in ``self.init_process()``.\n        \"\"\"\n        self.age = age\n        self.ppid = ppid\n        self.sockets = sockets\n        self.app = app\n        self.timeout = timeout\n        self.cfg = cfg\n        self.booted = False\n        self.aborted = False\n        self.reloader = None\n\n        self.nr = 0\n        jitter = randint(0, cfg.max_requests_jitter)\n        self.max_requests = cfg.max_requests + jitter or MAXSIZE\n        self.alive = True\n        self.log = log\n        self.tmp = WorkerTmp(cfg)\n\n    def __str__(self):\n        return \"<Worker %s>\" % self.pid\n\n    @property\n    def pid(self):\n        return os.getpid()\n\n    def notify(self):\n        \"\"\"\\\n        Your worker subclass must arrange to have this method called\n        once every ``self.timeout`` seconds. If you fail in accomplishing\n        this task, the master process will murder your workers.\n        \"\"\"\n        self.tmp.notify()\n\n    def run(self):\n        \"\"\"\\\n        This is the mainloop of a worker process. You should override\n        this method in a subclass to provide the intended behaviour\n        for your particular evil schemes.\n        \"\"\"\n        raise NotImplementedError()\n\n    def init_process(self):\n        \"\"\"\\\n        If you override this method in a subclass, the last statement\n        in the function should be to call this method with\n        super(MyWorkerClass, self).init_process() so that the ``run()``\n        loop is initiated.\n        \"\"\"\n\n        # start the reloader\n        if self.cfg.reload:\n            def changed(fname):\n                self.log.info(\"Worker reloading: %s modified\", fname)\n                os.kill(self.pid, signal.SIGQUIT)\n            self.reloader = Reloader(callback=changed)\n            self.reloader.start()\n\n        # set environment' variables\n        if self.cfg.env:\n            for k, v in self.cfg.env.items():\n                os.environ[k] = v\n\n        util.set_owner_process(self.cfg.uid, self.cfg.gid)\n\n        # Reseed the random number generator\n        util.seed()\n\n        # For waking ourselves up\n        self.PIPE = os.pipe()\n        for p in self.PIPE:\n            util.set_non_blocking(p)\n            util.close_on_exec(p)\n\n        # Prevent fd inheritance\n        [util.close_on_exec(s) for s in self.sockets]\n        util.close_on_exec(self.tmp.fileno())\n\n        self.log.close_on_exec()\n\n        self.init_signals()\n\n        self.cfg.post_worker_init(self)\n\n        self.load_wsgi()\n\n        # Enter main run loop\n        self.booted = True\n        self.run()\n\n    def load_wsgi(self):\n        try:\n            self.wsgi = self.app.wsgi()\n        except SyntaxError as e:\n            if not self.cfg.reload:\n                raise\n\n            self.log.exception(e)\n\n            exc_type, exc_val, exc_tb = sys.exc_info()\n            self.reloader.add_extra_file(exc_val.filename)\n\n            tb_string = traceback.format_exc(exc_tb)\n            self.wsgi = util.make_fail_app(tb_string)\n\n    def init_signals(self):\n        # reset signaling\n        [signal.signal(s, signal.SIG_DFL) for s in self.SIGNALS]\n        # init new signaling\n        signal.signal(signal.SIGQUIT, self.handle_quit)\n        signal.signal(signal.SIGTERM, self.handle_exit)\n        signal.signal(signal.SIGINT, self.handle_quit)\n        signal.signal(signal.SIGWINCH, self.handle_winch)\n        signal.signal(signal.SIGUSR1, self.handle_usr1)\n        signal.signal(signal.SIGABRT, self.handle_abort)\n\n        # Don't let SIGTERM and SIGUSR1 disturb active requests\n        # by interrupting system calls\n        if hasattr(signal, 'siginterrupt'):  # python >= 2.6\n            signal.siginterrupt(signal.SIGTERM, False)\n            signal.siginterrupt(signal.SIGUSR1, False)\n\n    def handle_usr1(self, sig, frame):\n        self.log.reopen_files()\n\n    def handle_exit(self, sig, frame):\n        self.alive = False\n\n    def handle_quit(self, sig, frame):\n        self.alive = False\n        # worker_int callback\n        self.cfg.worker_int(self)\n        time.sleep(0.1)\n        sys.exit(0)\n\n    def handle_abort(self, sig, frame):\n        self.alive = False\n        self.cfg.worker_abort(self)\n        sys.exit(1)\n\n    def handle_error(self, req, client, addr, exc):\n        request_start = datetime.now()\n        addr = addr or ('', -1)  # unix socket case\n        if isinstance(exc, (InvalidRequestLine, InvalidRequestMethod,\n                InvalidHTTPVersion, InvalidHeader, InvalidHeaderName,\n                LimitRequestLine, LimitRequestHeaders,\n                InvalidProxyLine, ForbiddenProxyRequest)):\n\n            status_int = 400\n            reason = \"Bad Request\"\n\n            if isinstance(exc, InvalidRequestLine):\n                mesg = \"Invalid Request Line '%s'\" % str(exc)\n            elif isinstance(exc, InvalidRequestMethod):\n                mesg = \"Invalid Method '%s'\" % str(exc)\n            elif isinstance(exc, InvalidHTTPVersion):\n                mesg = \"Invalid HTTP Version '%s'\" % str(exc)\n            elif isinstance(exc, (InvalidHeaderName, InvalidHeader,)):\n                mesg = \"%s\" % str(exc)\n                if not req and hasattr(exc, \"req\"):\n                    req = exc.req  # for access log\n            elif isinstance(exc, LimitRequestLine):\n                mesg = \"%s\" % str(exc)\n            elif isinstance(exc, LimitRequestHeaders):\n                mesg = \"Error parsing headers: '%s'\" % str(exc)\n            elif isinstance(exc, InvalidProxyLine):\n                mesg = \"'%s'\" % str(exc)\n            elif isinstance(exc, ForbiddenProxyRequest):\n                reason = \"Forbidden\"\n                mesg = \"Request forbidden\"\n                status_int = 403\n\n            msg = \"Invalid request from ip={ip}: {error}\"\n            self.log.debug(msg.format(ip=addr[0], error=str(exc)))\n        else:\n            self.log.exception(\"Error handling request %s\", req.uri)\n\n            status_int = 500\n            reason = \"Internal Server Error\"\n            mesg = \"\"\n\n        if req is not None:\n            request_time = datetime.now() - request_start\n            environ = default_environ(req, client, self.cfg)\n            environ['REMOTE_ADDR'] = addr[0]\n            environ['REMOTE_PORT'] = str(addr[1])\n            resp = Response(req, client, self.cfg)\n            resp.status = \"%s %s\" % (status_int, reason)\n            resp.response_length = len(mesg)\n            self.log.access(resp, req, environ, request_time)\n\n        try:\n            util.write_error(client, status_int, reason, mesg)\n        except:\n            self.log.debug(\"Failed to send error message.\")\n\n    def handle_winch(self, sig, fname):\n        # Ignore SIGWINCH in worker. Fixes a crash on OpenBSD.\n        return\n", "path": "gunicorn/workers/base.py"}]}