Skip to content

Commit 5d51424

Browse files
meili-bors[bot]sanders41alallema
authored
Merge #763
763: Don't send body for get requests r=alallema a=sanders41 # Pull Request ## Related issue Fixes #762 ## What does this PR do? - Makes it where the body isn't sent with the request if it is empty. ## PR checklist Please check if your PR fulfills the following requirements: - [x] Does this PR fix an existing issue, or have you listed the changes applied in the PR description (and why they are needed)? - [x] Have you read the contributing guidelines? - [x] Have you made sure that the title is accurate and descriptive of the changes? Thank you so much for contributing to Meilisearch! Co-authored-by: Paul Sanders <[email protected]> Co-authored-by: Amélie <[email protected]>
2 parents 5f2a78f + d1faeb4 commit 5d51424

File tree

4 files changed

+10
-2
lines changed

4 files changed

+10
-2
lines changed

meilisearch/_httprequests.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,13 @@ def send_request(
3333
self.headers["Content-Type"] = content_type
3434
try:
3535
request_path = self.config.url + "/" + path
36-
if isinstance(body, bytes):
36+
if http_method.__name__ == "get":
37+
request = http_method(
38+
request_path,
39+
timeout=self.config.timeout,
40+
headers=self.headers,
41+
)
42+
elif isinstance(body, bytes):
3743
request = http_method(
3844
request_path,
3945
timeout=self.config.timeout,

tests/errors/test_api_error_meilisearch.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def test_meilisearch_api_error_wrong_master_key():
2525
@patch("requests.post")
2626
def test_meilisearch_api_error_no_code(mock_post):
2727
"""Here to test for regressions related to https://github.com/meilisearch/meilisearch-python/issues/305."""
28-
28+
mock_post.configure_mock(__name__="post")
2929
mock_response = requests.models.Response()
3030
mock_response.status_code = 408
3131
mock_post.return_value = mock_response

tests/errors/test_communication_error_meilisearch.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
@patch("requests.post")
1414
def test_meilisearch_communication_error_host(mock_post):
15+
mock_post.configure_mock(__name__="post")
1516
mock_post.side_effect = requests.exceptions.ConnectionError()
1617
client = meilisearch.Client("http://wrongurl:1234", MASTER_KEY)
1718
with pytest.raises(MeilisearchCommunicationError):

tests/errors/test_timeout_error_meilisearch.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
@patch("requests.get")
1212
def test_client_timeout_error(mock_get):
13+
mock_get.configure_mock(__name__="get")
1314
mock_get.side_effect = requests.exceptions.Timeout()
1415
client = meilisearch.Client(BASE_URL, MASTER_KEY, timeout=1)
1516

0 commit comments

Comments
 (0)