当前位置: 首页>>代码示例>>Python>>正文


Python httputil.HTTPServerConnectionDelegate方法代码示例

本文整理汇总了Python中tornado.httputil.HTTPServerConnectionDelegate方法的典型用法代码示例。如果您正苦于以下问题:Python httputil.HTTPServerConnectionDelegate方法的具体用法?Python httputil.HTTPServerConnectionDelegate怎么用?Python httputil.HTTPServerConnectionDelegate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在tornado.httputil的用法示例。


在下文中一共展示了httputil.HTTPServerConnectionDelegate方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get_target_delegate

# 需要导入模块: from tornado import httputil [as 别名]
# 或者: from tornado.httputil import HTTPServerConnectionDelegate [as 别名]
def get_target_delegate(self, target, request, **target_params):
        """Returns an instance of `~.httputil.HTTPMessageDelegate` for a
        Rule's target. This method is called by `~.find_handler` and can be
        extended to provide additional target types.

        :arg target: a Rule's target.
        :arg httputil.HTTPServerRequest request: current request.
        :arg target_params: additional parameters that can be useful
            for `~.httputil.HTTPMessageDelegate` creation.
        """
        if isinstance(target, Router):
            return target.find_handler(request, **target_params)

        elif isinstance(target, httputil.HTTPServerConnectionDelegate):
            return target.start_request(request.server_connection, request.connection)

        elif callable(target):
            return _CallableAdapter(
                partial(target, **target_params), request.connection
            )

        return None 
开发者ID:tp4a,项目名称:teleport,代码行数:24,代码来源:routing.py

示例2: __init__

# 需要导入模块: from tornado import httputil [as 别名]
# 或者: from tornado.httputil import HTTPServerConnectionDelegate [as 别名]
def __init__(self, server, server_conn, request_conn):
        self.server = server
        self.connection = request_conn
        self.request = None
        if isinstance(server.request_callback,
                      httputil.HTTPServerConnectionDelegate):
            self.delegate = server.request_callback.start_request(
                server_conn, request_conn)
            self._chunks = None
        else:
            self.delegate = None
            self._chunks = [] 
开发者ID:tao12345666333,项目名称:tornado-zh,代码行数:14,代码来源:httpserver.py

示例3: get_app

# 需要导入模块: from tornado import httputil [as 别名]
# 或者: from tornado.httputil import HTTPServerConnectionDelegate [as 别名]
def get_app(self):
        class App(HTTPServerConnectionDelegate):
            def start_request(self, server_conn, request_conn):
                return StreamingChunkSizeTest.MessageDelegate(request_conn)
        return App() 
开发者ID:tao12345666333,项目名称:tornado-zh,代码行数:7,代码来源:httpserver_test.py

示例4: start_serving

# 需要导入模块: from tornado import httputil [as 别名]
# 或者: from tornado.httputil import HTTPServerConnectionDelegate [as 别名]
def start_serving(self, delegate):
        """Starts serving requests on this connection.

        :arg delegate: a `.HTTPServerConnectionDelegate`
        """
        assert isinstance(delegate, httputil.HTTPServerConnectionDelegate)
        self._serving_future = self._server_request_loop(delegate)
        # Register the future on the IOLoop so its errors get logged.
        self.stream.io_loop.add_future(self._serving_future,
                                       lambda f: f.result()) 
开发者ID:tao12345666333,项目名称:tornado-zh,代码行数:12,代码来源:http1connection.py

示例5: start_request

# 需要导入模块: from tornado import httputil [as 别名]
# 或者: from tornado.httputil import HTTPServerConnectionDelegate [as 别名]
def start_request(
        self, server_conn: object, request_conn: httputil.HTTPConnection
    ) -> httputil.HTTPMessageDelegate:
        if isinstance(self.request_callback, httputil.HTTPServerConnectionDelegate):
            delegate = self.request_callback.start_request(server_conn, request_conn)
        else:
            delegate = _CallableAdapter(self.request_callback, request_conn)

        if self.xheaders:
            delegate = _ProxyAdapter(delegate, request_conn)

        return delegate 
开发者ID:opendevops-cn,项目名称:opendevops,代码行数:14,代码来源:httpserver.py

示例6: __init__

# 需要导入模块: from tornado import httputil [as 别名]
# 或者: from tornado.httputil import HTTPServerConnectionDelegate [as 别名]
def __init__(self, rules: _RuleList = None) -> None:
        """Constructs a router from an ordered list of rules::

            RuleRouter([
                Rule(PathMatches("/handler"), Target),
                # ... more rules
            ])

        You can also omit explicit `Rule` constructor and use tuples of arguments::

            RuleRouter([
                (PathMatches("/handler"), Target),
            ])

        `PathMatches` is a default matcher, so the example above can be simplified::

            RuleRouter([
                ("/handler", Target),
            ])

        In the examples above, ``Target`` can be a nested `Router` instance, an instance of
        `~.httputil.HTTPServerConnectionDelegate` or an old-style callable,
        accepting a request argument.

        :arg rules: a list of `Rule` instances or tuples of `Rule`
            constructor arguments.
        """
        self.rules = []  # type: List[Rule]
        if rules:
            self.add_rules(rules) 
开发者ID:opendevops-cn,项目名称:opendevops,代码行数:32,代码来源:routing.py

示例7: get_target_delegate

# 需要导入模块: from tornado import httputil [as 别名]
# 或者: from tornado.httputil import HTTPServerConnectionDelegate [as 别名]
def get_target_delegate(
        self, target: Any, request: httputil.HTTPServerRequest, **target_params: Any
    ) -> Optional[httputil.HTTPMessageDelegate]:
        """Returns an instance of `~.httputil.HTTPMessageDelegate` for a
        Rule's target. This method is called by `~.find_handler` and can be
        extended to provide additional target types.

        :arg target: a Rule's target.
        :arg httputil.HTTPServerRequest request: current request.
        :arg target_params: additional parameters that can be useful
            for `~.httputil.HTTPMessageDelegate` creation.
        """
        if isinstance(target, Router):
            return target.find_handler(request, **target_params)

        elif isinstance(target, httputil.HTTPServerConnectionDelegate):
            assert request.connection is not None
            return target.start_request(request.server_connection, request.connection)

        elif callable(target):
            assert request.connection is not None
            return _CallableAdapter(
                partial(target, **target_params), request.connection
            )

        return None 
开发者ID:opendevops-cn,项目名称:opendevops,代码行数:28,代码来源:routing.py

示例8: _server_request_loop

# 需要导入模块: from tornado import httputil [as 别名]
# 或者: from tornado.httputil import HTTPServerConnectionDelegate [as 别名]
def _server_request_loop(
        self, delegate: httputil.HTTPServerConnectionDelegate
    ) -> None:
        try:
            while True:
                conn = HTTP1Connection(self.stream, False, self.params, self.context)
                request_delegate = delegate.start_request(self, conn)
                try:
                    ret = await conn.read_response(request_delegate)
                except (
                    iostream.StreamClosedError,
                    iostream.UnsatisfiableReadError,
                    asyncio.CancelledError,
                ):
                    return
                except _QuietException:
                    # This exception was already logged.
                    conn.close()
                    return
                except Exception:
                    gen_log.error("Uncaught exception", exc_info=True)
                    conn.close()
                    return
                if not ret:
                    return
                await asyncio.sleep(0)
        finally:
            delegate.on_close(self) 
开发者ID:opendevops-cn,项目名称:opendevops,代码行数:30,代码来源:http1connection.py

示例9: start_request

# 需要导入模块: from tornado import httputil [as 别名]
# 或者: from tornado.httputil import HTTPServerConnectionDelegate [as 别名]
def start_request(self, server_conn, request_conn):
        if isinstance(self.request_callback, httputil.HTTPServerConnectionDelegate):
            delegate = self.request_callback.start_request(server_conn, request_conn)
        else:
            delegate = _CallableAdapter(self.request_callback, request_conn)

        if self.xheaders:
            delegate = _ProxyAdapter(delegate, request_conn)

        return delegate 
开发者ID:tp4a,项目名称:teleport,代码行数:12,代码来源:httpserver.py

示例10: __init__

# 需要导入模块: from tornado import httputil [as 别名]
# 或者: from tornado.httputil import HTTPServerConnectionDelegate [as 别名]
def __init__(self, rules=None):
        """Constructs a router from an ordered list of rules::

            RuleRouter([
                Rule(PathMatches("/handler"), Target),
                # ... more rules
            ])

        You can also omit explicit `Rule` constructor and use tuples of arguments::

            RuleRouter([
                (PathMatches("/handler"), Target),
            ])

        `PathMatches` is a default matcher, so the example above can be simplified::

            RuleRouter([
                ("/handler", Target),
            ])

        In the examples above, ``Target`` can be a nested `Router` instance, an instance of
        `~.httputil.HTTPServerConnectionDelegate` or an old-style callable,
        accepting a request argument.

        :arg rules: a list of `Rule` instances or tuples of `Rule`
            constructor arguments.
        """
        self.rules = []  # type: typing.List[Rule]
        if rules:
            self.add_rules(rules) 
开发者ID:tp4a,项目名称:teleport,代码行数:32,代码来源:routing.py

示例11: start_serving

# 需要导入模块: from tornado import httputil [as 别名]
# 或者: from tornado.httputil import HTTPServerConnectionDelegate [as 别名]
def start_serving(self, delegate: httputil.HTTPServerConnectionDelegate) -> None:
        """Starts serving requests on this connection.

        :arg delegate: a `.HTTPServerConnectionDelegate`
        """
        assert isinstance(delegate, httputil.HTTPServerConnectionDelegate)
        fut = gen.convert_yielded(self._server_request_loop(delegate))
        self._serving_future = fut
        # Register the future on the IOLoop so its errors get logged.
        self.stream.io_loop.add_future(fut, lambda f: f.result()) 
开发者ID:tp4a,项目名称:teleport,代码行数:12,代码来源:http1connection.py


注:本文中的tornado.httputil.HTTPServerConnectionDelegate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。