Python twisted.web.http.parse_qs() Examples
The following are 5
code examples of twisted.web.http.parse_qs().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
twisted.web.http
, or try the search function
.
Example #1
Source File: endpoint.py From txamqp with Apache License 2.0 | 6 votes |
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)
Example #2
Source File: test_http.py From Safejumper-for-Desktop with GNU General Public License v2.0 | 5 votes |
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"))
Example #3
Source File: test_http.py From learn_python3_spider with MIT License | 5 votes |
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"))
Example #4
Source File: test_http.py From python-for-android with Apache License 2.0 | 5 votes |
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"))
Example #5
Source File: test_http.py From BitTorrent with GNU General Public License v3.0 | 5 votes |
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"))