Skip to content

Commit 969850e

Browse files
authored
Merge pull request #328 from aimhubio/hop-by-hop-header-handling
[bugfix] Hop by hop header handling
2 parents a68623e + 4aebc0f commit 969850e

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

jupyter_server_proxy/handlers.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -280,8 +280,23 @@ async def proxy(self, host, port, proxied_path):
280280
"See https://jupyter-server-proxy.readthedocs.io/en/latest/arbitrary-ports-hosts.html for info.".format(host=host))
281281
return
282282

283-
if 'Proxy-Connection' in self.request.headers:
284-
del self.request.headers['Proxy-Connection']
283+
# Remove hop-by-hop headers that don't necessarily apply to the request we are making
284+
# to the backend. See https://github.com/jupyterhub/jupyter-server-proxy/pull/328
285+
# for more information
286+
hop_by_hop_headers = [
287+
'Proxy-Connection',
288+
'Keep-Alive',
289+
'Transfer-Encoding',
290+
'TE',
291+
'Connection',
292+
'Trailer',
293+
'Upgrade',
294+
'Proxy-Authorization',
295+
'Proxy-Authenticate'
296+
]
297+
for header_to_remove in hop_by_hop_headers:
298+
if header_to_remove in self.request.headers:
299+
del self.request.headers[header_to_remove]
285300

286301
self._record_activity()
287302

0 commit comments

Comments
 (0)