Skip to content

Commit b83eb8a

Browse files
committed
Let subclasses add proxy request headers.
1 parent f020e78 commit b83eb8a

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

nbserverproxy/handlers.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,9 +233,11 @@ async def proxy(self, port, proxied_path):
233233

234234
client = httpclient.AsyncHTTPClient()
235235

236+
headers = self.proxy_request_headers()
237+
236238
req = httpclient.HTTPRequest(
237239
client_uri, method=self.request.method, body=body,
238-
headers=self.request.headers,
240+
headers=headers,
239241
**self.proxy_request_options())
240242

241243
response = await client.fetch(req, raise_error=False)
@@ -261,6 +263,11 @@ async def proxy(self, port, proxied_path):
261263
if response.body:
262264
self.write(response.body)
263265

266+
def proxy_request_headers(self):
267+
'''A dictionary of headers to be used when constructing
268+
a tornado.httpclient.HTTPRequest instance for the proxy request.'''
269+
return self.request.headers.copy()
270+
264271
def proxy_request_options(self):
265272
'''A dictionary of options to be used when constructing
266273
a tornado.httpclient.HTTPRequest instance for the proxy request.'''

0 commit comments

Comments
 (0)