URL encodes the parameters. :param params: The parameters :type params: list of key/value tuples. :rtype: string
(params)
| 493 | |
| 494 | |
| 495 | def urlencode_params(params): |
| 496 | """URL encodes the parameters. |
| 497 | |
| 498 | :param params: The parameters |
| 499 | :type params: list of key/value tuples. |
| 500 | |
| 501 | :rtype: string |
| 502 | """ |
| 503 | # urlencode does not handle unicode strings in Python 2. |
| 504 | # Firstly, normalize the values so they get encoded correctly. |
| 505 | extended = [] |
| 506 | for key, val in params: |
| 507 | if isinstance(val, (list, tuple)): |
| 508 | for v in val: |
| 509 | extended.append((key, normalize_for_urlencode(v))) |
| 510 | else: |
| 511 | extended.append((key, normalize_for_urlencode(val))) |
| 512 | # Secondly, unquote unreserved chars which are incorrectly quoted |
| 513 | # by urllib.urlencode, causing invalid auth signatures. See GH #72 |
| 514 | # for more info. |
| 515 | return requests.utils.unquote_unreserved(urlencode(extended)) |
| 516 | |
| 517 | |
| 518 | try: |
no test coverage detected