Skip to content

Commit

Permalink
chore(connection): content type doesn't have to be parametrized (#752)
Browse files Browse the repository at this point in the history
  • Loading branch information
jnussbaum committed Jan 22, 2024
1 parent bac7c79 commit 2c0febb
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 8 deletions.
2 changes: 0 additions & 2 deletions src/dsp_tools/utils/connection.py
Expand Up @@ -30,7 +30,6 @@ def put(
route: str,
data: dict[str, Any] | None = None,
headers: dict[str, str] | None = None,
content_type: str = "application/json",
) -> dict[str, Any]:
"""
Make a HTTP GET request to the server to which this connection has been established.
Expand All @@ -39,7 +38,6 @@ def put(
route: route that will be called on the server
data: payload of the HTTP request
headers: headers for the HTTP request
content_type: HTTP Content-Type [default: 'application/json']
"""

def post(
Expand Down
8 changes: 4 additions & 4 deletions src/dsp_tools/utils/connection_live.py
Expand Up @@ -116,7 +116,8 @@ def post(
url = self.server + route
if data:
headers = headers or {}
headers["Content-Type"] = "application/json; charset=UTF-8"
if "Content-Type" not in headers:
headers["Content-Type"] = "application/json; charset=UTF-8"
timeout = timeout or self.timeout_put_post

self._log_request(
Expand Down Expand Up @@ -184,7 +185,6 @@ def put(
route: str,
data: dict[str, Any] | None = None,
headers: dict[str, str] | None = None,
content_type: str = "application/json",
) -> dict[str, Any]:
"""
Make a HTTP GET request to the server to which this connection has been established.
Expand All @@ -193,7 +193,6 @@ def put(
route: route that will be called on the server
data: payload of the HTTP request
headers: headers of the HTTP request
content_type: HTTP Content-Type [default: 'application/json']
Returns:
response from server
Expand All @@ -206,7 +205,8 @@ def put(
url = self.server + route
if data:
headers = headers or {}
headers["Content-Type"] = f"{content_type}; charset=UTF-8"
if "Content-Type" not in headers:
headers["Content-Type"] = "application/json; charset=UTF-8"
timeout = self.timeout_put_post

self._log_request(
Expand Down
1 change: 0 additions & 1 deletion test/unittests/commands/xmlupload/connection_mock.py
Expand Up @@ -19,7 +19,6 @@ def put(
route: str,
data: dict[str, Any] | None = None,
headers: dict[str, str] | None = None,
content_type: str = "application/json",
) -> dict[str, Any]:
raise AssertionError("PUT not implemented in mock")

Expand Down
Expand Up @@ -65,7 +65,6 @@ def put(
route: str,
data: dict[str, Any] | None = None,
headers: dict[str, str] | None = None,
content_type: str = "application/json",
) -> dict[str, Any]:
return self.put_responses.pop(0)

Expand Down

0 comments on commit 2c0febb

Please sign in to comment.