Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

test_classes: Default client_post to application/x-www-form-urlencoded.

Anders Kaseorga356ec701108
diff --git a/zerver/lib/test_classes.py b/zerver/lib/test_classes.py
index 4388f763f0e..f9cbc257b1e 100644
--- a/zerver/lib/test_classes.py
+++ b/zerver/lib/test_classes.py
@@ -532,12 +532,28 @@ Output:
secure: bool = False,
headers: Optional[Mapping[str, Any]] = None,
intentionally_undocumented: bool = False,
+ content_type: Optional[str] = None,
**extra: str,
) -> "TestHttpResponse":
django_client = self.client # see WRAPPER_COMMENT
self.set_http_headers(extra, skip_user_agent)
+ encoded = info
+ if content_type is None:
+ if isinstance(info, dict) and not any(
+ hasattr(value, "read") and callable(value.read) for value in info.values()
+ ):
+ content_type = "application/x-www-form-urlencoded"
+ encoded = urlencode(info, doseq=True)
+ else:
+ content_type = MULTIPART_CONTENT
result = django_client.post(
- url, info, follow=follow, secure=secure, headers=headers, **extra
+ url,
+ encoded,
+ follow=follow,
+ secure=secure,
+ headers=headers,
+ content_type=content_type,
+ **extra,
)
self.validate_api_response_openapi(
url,