From 51e88ea170a1abec6cb87cef643e8b1459790ef7 Mon Sep 17 00:00:00 2001 From: Nick Mastoris Date: Mon, 8 Jul 2024 05:48:00 +0000 Subject: [PATCH 1/2] Support multiple values for a key param --- src/idpyoidc/message/__init__.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/idpyoidc/message/__init__.py b/src/idpyoidc/message/__init__.py index 41a4ddb5..cfd8a363 100644 --- a/src/idpyoidc/message/__init__.py +++ b/src/idpyoidc/message/__init__.py @@ -79,10 +79,11 @@ def set_defaults(self): for key, val in self.c_default.items(): self._dict.setdefault(key, val) - def to_urlencoded(self): + def to_urlencoded(self, doseq=False): """ Creates a string using the application/x-www-form-urlencoded format + :doseq: If set to true, key=value pairs separated by '&' are generated for each element of the value sequence for the key. :return: A string of the application/x-www-form-urlencoded format """ @@ -135,7 +136,7 @@ def to_urlencoded(self): params.append((key, str(val))) try: - return urlencode(params) + return urlencode(params, doseq) except UnicodeEncodeError: _val = [] for k, v in params: @@ -143,7 +144,7 @@ def to_urlencoded(self): _val.append((k, v.encode("utf-8"))) except TypeError: _val.append((k, v)) - return urlencode(_val) + return urlencode(_val, doseq) def serialize(self, method="urlencoded", **kwargs): """ From 4b325b46ceafd23ce8b65578a2c8dca93b128b88 Mon Sep 17 00:00:00 2001 From: Nick Mastoris Date: Mon, 8 Jul 2024 06:02:07 +0000 Subject: [PATCH 2/2] minor fix --- src/idpyoidc/message/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/idpyoidc/message/__init__.py b/src/idpyoidc/message/__init__.py index cfd8a363..46d23440 100644 --- a/src/idpyoidc/message/__init__.py +++ b/src/idpyoidc/message/__init__.py @@ -136,7 +136,7 @@ def to_urlencoded(self, doseq=False): params.append((key, str(val))) try: - return urlencode(params, doseq) + return urlencode(params, doseq=doseq) except UnicodeEncodeError: _val = [] for k, v in params: @@ -144,7 +144,7 @@ def to_urlencoded(self, doseq=False): _val.append((k, v.encode("utf-8"))) except TypeError: _val.append((k, v)) - return urlencode(_val, doseq) + return urlencode(_val, doseq=doseq) def serialize(self, method="urlencoded", **kwargs): """