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


Python URL.with_fragment方法代码示例

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


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

示例1: __init__

# 需要导入模块: from yarl import URL [as 别名]
# 或者: from yarl.URL import with_fragment [as 别名]
    def __init__(self, method: str, url: URL, *,
                 writer: 'asyncio.Task[None]',
                 continue100: Optional['asyncio.Future[bool]'],
                 timer: BaseTimerContext,
                 request_info: RequestInfo,
                 traces: List['Trace'],
                 loop: asyncio.AbstractEventLoop,
                 session: 'ClientSession') -> None:
        assert isinstance(url, URL)

        self.method = method
        self.cookies = SimpleCookie()

        self._real_url = url
        self._url = url.with_fragment(None)
        self._body = None  # type: Any
        self._writer = writer  # type: Optional[asyncio.Task[None]]
        self._continue = continue100  # None by default
        self._closed = True
        self._history = ()  # type: Tuple[ClientResponse, ...]
        self._request_info = request_info
        self._timer = timer if timer is not None else TimerNoop()
        self._cache = {}  # type: Dict[str, Any]
        self._traces = traces
        self._loop = loop
        # store a reference to session #1985
        self._session = session  # type: Optional[ClientSession]
        if loop.get_debug():
            self._source_traceback = traceback.extract_stack(sys._getframe(1))
开发者ID:wwqgtxx,项目名称:wwqLyParse,代码行数:31,代码来源:client_reqrep.py

示例2: test_response_real_url

# 需要导入模块: from yarl import URL [as 别名]
# 或者: from yarl.URL import with_fragment [as 别名]
def test_response_real_url(loop, session) -> None:
    url = URL('http://def-cl-resp.org/#urlfragment')
    response = ClientResponse('get', url,
                              request_info=mock.Mock(),
                              writer=mock.Mock(),
                              continue100=None,
                              timer=TimerNoop(),
                              traces=[],
                              loop=loop,
                              session=session)
    assert response.url == url.with_fragment(None)
    assert response.real_url == url
开发者ID:KeepSafe,项目名称:aiohttp,代码行数:14,代码来源:test_client_response.py

示例3: test_with_fragment_bad_type

# 需要导入模块: from yarl import URL [as 别名]
# 或者: from yarl.URL import with_fragment [as 别名]
def test_with_fragment_bad_type():
    url = URL("http://example.com")
    with pytest.raises(TypeError):
        url.with_fragment(123)
开发者ID:asvetlov,项目名称:yarl,代码行数:6,代码来源:test_url.py

示例4: test_with_fragment_None

# 需要导入模块: from yarl import URL [as 别名]
# 或者: from yarl.URL import with_fragment [as 别名]
def test_with_fragment_None():
    url = URL("http://example.com/path#frag")
    url2 = url.with_fragment(None)
    assert str(url2) == "http://example.com/path"
开发者ID:asvetlov,项目名称:yarl,代码行数:6,代码来源:test_url.py

示例5: test_with_fragment_non_ascii

# 需要导入模块: from yarl import URL [as 别名]
# 或者: from yarl.URL import with_fragment [as 别名]
def test_with_fragment_non_ascii():
    url = URL("http://example.com")
    url2 = url.with_fragment("фрагм")
    assert url2.raw_fragment == "%D1%84%D1%80%D0%B0%D0%B3%D0%BC"
    assert url2.fragment == "фрагм"
开发者ID:asvetlov,项目名称:yarl,代码行数:7,代码来源:test_url.py

示例6: test_with_fragment_safe

# 需要导入模块: from yarl import URL [as 别名]
# 或者: from yarl.URL import with_fragment [as 别名]
def test_with_fragment_safe():
    url = URL("http://example.com")
    u2 = url.with_fragment("a:[email protected]/e")
    assert str(u2) == "http://example.com/#a:[email protected]/e"
开发者ID:asvetlov,项目名称:yarl,代码行数:6,代码来源:test_url.py

示例7: test_with_fragment

# 需要导入模块: from yarl import URL [as 别名]
# 或者: from yarl.URL import with_fragment [as 别名]
def test_with_fragment():
    url = URL("http://example.com")
    assert str(url.with_fragment("frag")) == "http://example.com/#frag"
开发者ID:asvetlov,项目名称:yarl,代码行数:5,代码来源:test_url.py

示例8: _request

# 需要导入模块: from yarl import URL [as 别名]
# 或者: from yarl.URL import with_fragment [as 别名]

#.........这里部分代码省略.........
            )
            for trace_config in self._trace_configs
        ]

        for trace in traces:
            await trace.send_request_start(
                method,
                url,
                headers
            )

        timer = tm.timer()
        try:
            with timer:
                while True:
                    url, auth_from_url = strip_auth_from_url(url)
                    if auth and auth_from_url:
                        raise ValueError("Cannot combine AUTH argument with "
                                         "credentials encoded in URL")

                    if auth is None:
                        auth = auth_from_url
                    if auth is None:
                        auth = self._default_auth
                    # It would be confusing if we support explicit
                    # Authorization header with auth argument
                    if (headers is not None and
                            auth is not None and
                            hdrs.AUTHORIZATION in headers):
                        raise ValueError("Cannot combine AUTHORIZATION header "
                                         "with AUTH argument or credentials "
                                         "encoded in URL")

                    url = url.with_fragment(None)
                    cookies = self._cookie_jar.filter_cookies(url)

                    if proxy is not None:
                        proxy = URL(proxy)
                    elif self._trust_env:
                        for scheme, proxy_info in proxies_from_env().items():
                            if scheme == url.scheme:
                                proxy = proxy_info.proxy
                                proxy_auth = proxy_info.proxy_auth
                                break

                    req = self._request_class(
                        method, url, params=params, headers=headers,
                        skip_auto_headers=skip_headers, data=data,
                        cookies=cookies, auth=auth, version=version,
                        compress=compress, chunked=chunked,
                        expect100=expect100, loop=self._loop,
                        response_class=self._response_class,
                        proxy=proxy, proxy_auth=proxy_auth, timer=timer,
                        session=self, auto_decompress=self._auto_decompress,
                        ssl=ssl, proxy_headers=proxy_headers)

                    # connection timeout
                    try:
                        with CeilTimeout(self._conn_timeout, loop=self._loop):
                            conn = await self._connector.connect(
                                req,
                                traces=traces
                            )
                    except asyncio.TimeoutError as exc:
                        raise ServerTimeoutError(
                            'Connection timeout '
开发者ID:youpengly,项目名称:aiohttp,代码行数:70,代码来源:client.py


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