@@ -35,12 +35,43 @@ class ProxyHandler(WebSocketHandlerMixin, IPythonHandler):
3535 used directly as a means of overriding CORS. This presents significant
3636 security risks, and could allow arbitrary remote code access. Instead, it is
3737 meant to be subclassed and used for proxying URLs from trusted sources.
38+
39+ Subclasses should implement open, http_get, post, put, delete, head, patch,
40+ and options.
3841 """
3942 def __init__ (self , * args , ** kwargs ):
4043 self .proxy_base = ''
4144 self .absolute_url = kwargs .pop ('absolute_url' , False )
4245 super ().__init__ (* args , ** kwargs )
4346
47+ # Support all the methods that torando does by default except for GET which
48+ # is passed to WebSocketHandlerMixin and then to WebSocketHandler.
49+
50+ async def open (self , port , proxied_path ):
51+ raise NotImplementedError ('Subclasses of ProxyHandler should implement open' )
52+
53+ async def http_get (self , host , port , proxy_path = '' ):
54+ '''Our non-websocket GET.'''
55+ raise NotImplementedError ('Subclasses of ProxyHandler should implement http_get' )
56+
57+ def post (self , host , port , proxy_path = '' ):
58+ raise NotImplementedError ('Subclasses of ProxyHandler should implement this post' )
59+
60+ def put (self , port , proxy_path = '' ):
61+ raise NotImplementedError ('Subclasses of ProxyHandler should implement this put' )
62+
63+ def delete (self , host , port , proxy_path = '' ):
64+ raise NotImplementedError ('Subclasses of ProxyHandler should implement delete' )
65+
66+ def head (self , host , port , proxy_path = '' ):
67+ raise NotImplementedError ('Subclasses of ProxyHandler should implement head' )
68+
69+ def patch (self , host , port , proxy_path = '' ):
70+ raise NotImplementedError ('Subclasses of ProxyHandler should implement patch' )
71+
72+ def options (self , host , port , proxy_path = '' ):
73+ raise NotImplementedError ('Subclasses of ProxyHandler should implement options' )
74+
4475 def on_message (self , message ):
4576 """
4677 Called when we receive a message from our client.
@@ -246,31 +277,6 @@ def proxy_request_options(self):
246277 a tornado.httpclient.HTTPRequest instance for the proxy request.'''
247278 return dict (follow_redirects = False )
248279
249- # Support all the methods that torando does by default except for GET which
250- # is passed to WebSocketHandlerMixin and then to WebSocketHandler.
251-
252- async def http_get (self , host , port , proxy_path = '' ):
253- '''Our non-websocket GET.'''
254- return await self .proxy (host , port , proxy_path )
255-
256- def post (self , host , port , proxy_path = '' ):
257- return self .proxy (host , port , proxy_path )
258-
259- def put (self , port , proxy_path = '' ):
260- return self .proxy (host , port , proxy_path )
261-
262- def delete (self , host , port , proxy_path = '' ):
263- return self .proxy (host , port , proxy_path )
264-
265- def head (self , host , port , proxy_path = '' ):
266- return self .proxy (host , port , proxy_path )
267-
268- def patch (self , host , port , proxy_path = '' ):
269- return self .proxy (host , port , proxy_path )
270-
271- def options (self , host , port , proxy_path = '' ):
272- return self .proxy (host , port , proxy_path )
273-
274280 def check_xsrf_cookie (self ):
275281 '''
276282 http://www.tornadoweb.org/en/stable/guide/security.html
0 commit comments