diff --git a/locust/clients.py b/locust/clients.py index 8e48dfee0f..cc11dd91fc 100644 --- a/locust/clients.py +++ b/locust/clients.py @@ -239,27 +239,30 @@ def _send_request_safe_mode(self, method, url, **kwargs): # These # type: ignore[override] comments below are needed because our overridden version of functions receives # more arguments than functions in the base class. def get(self, url: str | bytes, **kwargs: Unpack[RESTKwargs]): # type: ignore[override] - return super().get(url, **kwargs) # type: ignore[misc] + kwargs.setdefault("allow_redirects", True) + return self.request("GET", url, **kwargs) # type: ignore[misc] def options(self, url: str | bytes, **kwargs: Unpack[RESTKwargs]): # type: ignore[override] - return super().options(url, **kwargs) # type: ignore[misc] + kwargs.setdefault("allow_redirects", True) + return self.request("OPTIONS", url, **kwargs) # type: ignore[misc] def head(self, url: str | bytes, **kwargs: Unpack[RESTKwargs]): # type: ignore[override] - return super().head(url, **kwargs) # type: ignore[misc] + kwargs.setdefault("allow_redirects", False) + return self.request("HEAD", url, **kwargs) # type: ignore[misc] # These # type: ignore[misc] comments below are needed because data and json parameters are already defined in the # RESTKwargs TypedDict. An alternative approach is to define another TypedDict which doesn't contain them. def post(self, url: str | bytes, data: Any | None = None, json: Any | None = None, **kwargs: Unpack[RESTKwargs]): # type: ignore[override, misc] - return super().post(url, data=data, json=json, **kwargs) # type: ignore[misc] + return self.request("POST", url, data=data, json=json, **kwargs) # type: ignore[misc] def put(self, url: str | bytes, data: Any | None = None, **kwargs: Unpack[RESTKwargs]): # type: ignore[override, misc] - return super().put(url, data=data, **kwargs) # type: ignore[misc] + return self.request("PUT", url, data=data, **kwargs) # type: ignore[misc] def patch(self, url: str | bytes, data: Any | None = None, **kwargs: Unpack[RESTKwargs]): # type: ignore[override, misc] - return super().patch(url, data=data, **kwargs) # type: ignore[misc] + return self.request("PATCH", url, data=data, **kwargs) # type: ignore[misc] def delete(self, url: str | bytes, **kwargs: Unpack[RESTKwargs]): # type: ignore[override] - return super().delete(url, **kwargs) # type: ignore[misc] + return self.request("DELETE", url, **kwargs) # type: ignore[misc] class ResponseContextManager(LocustResponse):