Skip to content

Commit 8045522

Browse files
committed
Set content-type only for post and put
1 parent 9355cc5 commit 8045522

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

meilisearch/_httprequests.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ def __init__(self, config: Config) -> None:
1313
self.config = config
1414
self.headers = {
1515
'X-Meili-Api-Key': self.config.api_key,
16-
'Content-Type': 'application/json'
1716
}
1817

1918
def send_request(
@@ -27,7 +26,7 @@ def send_request(
2726
self.headers['Content-Type'] = content_type
2827
try:
2928
request_path = self.config.url + '/' + path
30-
if not content_type:
29+
if not content_type or content_type == 'application/json':
3130
request = http_method(
3231
request_path,
3332
timeout=self.config.timeout,
@@ -57,16 +56,17 @@ def post(
5756
self,
5857
path: str,
5958
body: Optional[Union[Dict[str, Any], List[Dict[str, Any]], List[str]]] = None,
60-
content_type: Optional[str] = None,
59+
content_type: Optional[str] = 'application/json',
6160
) -> Any:
6261
return self.send_request(requests.post, path, body, content_type)
6362

6463
def put(
6564
self,
6665
path: str,
6766
body: Optional[Union[Dict[str, Any], List[Dict[str, Any]], List[str]]] = None,
67+
content_type: Optional[str] = 'application/json',
6868
) -> Any:
69-
return self.send_request(requests.put, path, body)
69+
return self.send_request(requests.put, path, body, content_type)
7070

7171
def delete(
7272
self,

0 commit comments

Comments
 (0)