當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。