From: Ben Darnell Date: Sun, 5 Oct 2014 19:01:11 +0000 (-0400) Subject: Document the ability to pass lists of kv pairs to url-concat. X-Git-Tag: v4.1.0b1~76 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=27d67a2c51e9d461497bf968940fb7f77702b7db;p=thirdparty%2Ftornado.git Document the ability to pass lists of kv pairs to url-concat. Closes #1216. --- diff --git a/tornado/httputil.py b/tornado/httputil.py index 126db40e3..f5c9c04fe 100644 --- a/tornado/httputil.py +++ b/tornado/httputil.py @@ -562,11 +562,18 @@ class HTTPConnection(object): def url_concat(url, args): - """Concatenate url and argument dictionary regardless of whether + """Concatenate url and arguments regardless of whether url has existing query parameters. + ``args`` may be either a dictionary or a list of key-value pairs + (the latter allows for multiple values with the same key. + + >>> url_concat("http://example.com/foo", dict(c="d")) + 'http://example.com/foo?c=d' >>> url_concat("http://example.com/foo?a=b", dict(c="d")) 'http://example.com/foo?a=b&c=d' + >>> url_concat("http://example.com/foo?a=b", [("c", "d"), ("c", "d2")]) + 'http://example.com/foo?a=b&c=d&c=d2' """ if not args: return url