本文整理汇总了Python中twisted.web.http.parse_qs方法的典型用法代码示例。如果您正苦于以下问题:Python http.parse_qs方法的具体用法?Python http.parse_qs怎么用?Python http.parse_qs使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类twisted.web.http
的用法示例。
在下文中一共展示了http.parse_qs方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: from_uri
# 需要导入模块: from twisted.web import http [as 别名]
# 或者: from twisted.web.http import parse_qs [as 别名]
def from_uri(cls, reactor, uri):
"""Return an AMQEndpoint instance configured with the given AMQP uri.
@see: https://www.rabbitmq.com/uri-spec.html
"""
uri = URI.fromBytes(uri.encode(), defaultPort=5672)
kwargs = {}
host = uri.host.decode()
if "@" in host:
auth, host = uri.netloc.decode().split("@")
username, password = auth.split(":")
kwargs.update({"username": username, "password": password})
vhost = uri.path.decode()
if len(vhost) > 1:
vhost = vhost[1:] # Strip leading "/"
kwargs["vhost"] = vhost
params = parse_qs(uri.query)
kwargs.update({name.decode(): value[0].decode() for name, value in params.items()})
if "heartbeat" in kwargs:
kwargs["heartbeat"] = int(kwargs["heartbeat"])
return cls(reactor, host, uri.port, **kwargs)
示例2: testParseqs
# 需要导入模块: from twisted.web import http [as 别名]
# 或者: from twisted.web.http import parse_qs [as 别名]
def testParseqs(self):
self.assertEqual(
cgi.parse_qs(b"a=b&d=c;+=f"),
http.parse_qs(b"a=b&d=c;+=f"))
self.assertRaises(
ValueError, http.parse_qs, b"blah", strict_parsing=True)
self.assertEqual(
cgi.parse_qs(b"a=&b=c", keep_blank_values=1),
http.parse_qs(b"a=&b=c", keep_blank_values=1))
self.assertEqual(
cgi.parse_qs(b"a=&b=c"),
http.parse_qs(b"a=&b=c"))
示例3: testParseqs
# 需要导入模块: from twisted.web import http [as 别名]
# 或者: from twisted.web.http import parse_qs [as 别名]
def testParseqs(self):
self.failUnlessEqual(cgi.parse_qs("a=b&d=c;+=f"),
http.parse_qs("a=b&d=c;+=f"))
self.failUnlessRaises(ValueError, http.parse_qs, "blah",
strict_parsing = 1)
self.failUnlessEqual(cgi.parse_qs("a=&b=c", keep_blank_values = 1),
http.parse_qs("a=&b=c", keep_blank_values = 1))
self.failUnlessEqual(cgi.parse_qs("a=&b=c"),
http.parse_qs("a=&b=c"))