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


Python urls.url_decode_stream方法代码示例

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


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

示例1: request_authentication

# 需要导入模块: from werkzeug import urls [as 别名]
# 或者: from werkzeug.urls import url_decode_stream [as 别名]
def request_authentication(
        self, redirect_url: str
    ) -> AuthenticationContinuation:
        response = self.request('POST', self.REQUEST_TOKEN_URL.format(self))
        request_token = url_decode_stream(response)
        response.close()
        return AuthenticationContinuation(
            self.AUTHORIZE_URL.format(self) + '?' + url_encode({
                'oauth_token': request_token['oauth_token'],
                'oauth_callback': redirect_url
            }),
            (request_token['oauth_token'], request_token['oauth_token_secret'])
        ) 
开发者ID:spoqa,项目名称:geofront,代码行数:15,代码来源:stash.py

示例2: authenticate

# 需要导入模块: from werkzeug import urls [as 别名]
# 或者: from werkzeug.urls import url_decode_stream [as 别名]
def authenticate(self,
                     state,
                     requested_redirect_url: str,
                     wsgi_environ: Mapping[str, object]) -> Identity:
        logger = logging.getLogger(__name__ + '.StashTeam.authenticate')
        logger.debug('state = %r', state)
        try:
            oauth_token, oauth_token_secret = state
        except ValueError:
            raise AuthenticationError()
        req = Request(wsgi_environ, populate_request=False, shallow=True)
        args = cast(ImmutableMultiDict, req.args)
        logger.debug('req.args = %r', args)
        if args.get('oauth_token') != oauth_token:
            raise AuthenticationError()
        response = self.request(
            'POST', self.ACCESS_TOKEN_URL.format(self),
            resource_owner_key=oauth_token,
            resource_owner_secret=oauth_token_secret
        )
        access_token = url_decode_stream(response)
        logger.debug('access_token = %r', access_token)
        response.close()
        response = self.request(
            'GET', self.USER_URL.format(self),
            resource_owner_key=access_token['oauth_token'],
            resource_owner_secret=access_token['oauth_token_secret']
        )
        whoami = response.read().decode('utf-8')
        return Identity(
            type(self),
            self.USER_PROFILE_URL.format(self, whoami),
            (access_token['oauth_token'], access_token['oauth_token_secret'])
        ) 
开发者ID:spoqa,项目名称:geofront,代码行数:36,代码来源:stash.py

示例3: _parse_urlencoded

# 需要导入模块: from werkzeug import urls [as 别名]
# 或者: from werkzeug.urls import url_decode_stream [as 别名]
def _parse_urlencoded(self, stream, mimetype, content_length, options):
        if self.max_form_memory_size is not None and \
           content_length is not None and \
           content_length > self.max_form_memory_size:
            raise exceptions.RequestEntityTooLarge()
        form = url_decode_stream(stream, self.charset,
                                 errors=self.errors, cls=self.cls)
        return stream, form, self.cls()

    #: mapping of mimetypes to parsing functions 
开发者ID:jpush,项目名称:jbox,代码行数:12,代码来源:formparser.py

示例4: test_streamed_url_decoding

# 需要导入模块: from werkzeug import urls [as 别名]
# 或者: from werkzeug.urls import url_decode_stream [as 别名]
def test_streamed_url_decoding(self):
        item1 = u'a' * 100000
        item2 = u'b' * 400
        string = ('a=%s&b=%s&c=%s' % (item1, item2, item2)).encode('ascii')
        gen = urls.url_decode_stream(BytesIO(string), limit=len(string),
                                     return_iterator=True)
        self.assert_strict_equal(next(gen), ('a', item1))
        self.assert_strict_equal(next(gen), ('b', item2))
        self.assert_strict_equal(next(gen), ('c', item2))
        self.assert_raises(StopIteration, lambda: next(gen)) 
开发者ID:GeekTrainer,项目名称:Flask,代码行数:12,代码来源:urls.py

示例5: test_stream_decoding_string_fails

# 需要导入模块: from werkzeug import urls [as 别名]
# 或者: from werkzeug.urls import url_decode_stream [as 别名]
def test_stream_decoding_string_fails(self):
        self.assert_raises(TypeError, urls.url_decode_stream, 'testing') 
开发者ID:GeekTrainer,项目名称:Flask,代码行数:4,代码来源:urls.py

示例6: authenticate

# 需要导入模块: from werkzeug import urls [as 别名]
# 或者: from werkzeug.urls import url_decode_stream [as 别名]
def authenticate(
        self,
        state,
        requested_redirect_url: str,
        wsgi_environ: Mapping[str, object]
    ) -> Identity:
        logger = self.logger.getChild('authenticate')
        req = Request(wsgi_environ, populate_request=False, shallow=True)
        args = cast(ImmutableMultiDict, req.args)
        try:
            code = args['code']
            if args['state'] != state:
                raise AuthenticationError()
        except KeyError:
            raise AuthenticationError()
        data = url_encode({
            'client_id': self.client_id,
            'client_secret': self.client_secret,
            'code': code,
            'redirect_uri': requested_redirect_url,
            'grant_type': 'authorization_code',
        }).encode()
        try:
            response = urllib.request.urlopen(self.access_token_url, data)
        except urllib.error.HTTPError as e:
            logger.debug('Response of POST %s (with/ %r): %s\n%s',
                         self.access_token_url, data, e.code, e.read())
            raise
        assert isinstance(response, http.client.HTTPResponse), \
            'isinstance(response, {0.__module__}.{0.__qualname__})'.format(
                type(response))
        headers = getattr(response, 'headers')  # workaround mypy
        content_type = headers['Content-Type']
        mimetype, options = parse_options_header(content_type)
        if mimetype == 'application/x-www-form-urlencoded':
            token_data = url_decode_stream(response)
        elif mimetype == 'application/json':
            charset = options.get('charset', 'utf-8')
            token_data = json.load(
                io.TextIOWrapper(cast(IO[bytes], response), encoding=charset)
            )
        else:
            response.close()
            raise AuthenticationError(
                '{} sent unsupported content type: {}'.format(
                    self.access_token_url,
                    content_type
                )
            )
        response.close()
        identity = self.determine_identity(token_data['access_token'])
        if self.authorize(identity):
            return identity
        raise AuthenticationError(
            self.unauthorized_identity_message_format.format(
                identity=identity, team=self
            )
        ) 
开发者ID:spoqa,项目名称:geofront,代码行数:60,代码来源:oauth.py


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