Skip to content

Commit

Permalink
remove HEAD -> GET workaround
Browse files Browse the repository at this point in the history
  • Loading branch information
vcastane committed Mar 20, 2024
1 parent bd91530 commit 9560795
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 12 deletions.
8 changes: 2 additions & 6 deletions opensearchpy/_async/http_aiohttp.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,12 +246,8 @@ async def perform_request(
else:
query_string = ""

# There is a bug in aiohttp that disables the re-use
# of the connection in the pool when method=HEAD.
# See: aio-libs/aiohttp#1769
is_head = False
if method == "HEAD":
method = "GET"
is_head = True

# Top-tier tip-toeing happening here. Basically
Expand Down Expand Up @@ -301,9 +297,9 @@ async def perform_request(
timeout=timeout,
fingerprint=self.ssl_assert_fingerprint,
) as response:
if is_head: # We actually called 'GET' so throw away the data.
if is_head:
await response.release()
raw_data = ""
raw_data = "" # HEAD method has no response body

Check warning on line 302 in opensearchpy/_async/http_aiohttp.py

View check run for this annotation

Codecov / codecov/patch

opensearchpy/_async/http_aiohttp.py#L302

Added line #L302 was not covered by tests
else:
raw_data = await response.text()
duration = self.loop.time() - start
Expand Down
8 changes: 2 additions & 6 deletions opensearchpy/connection/http_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,12 +167,8 @@ async def perform_request(
else:
query_string = ""

# There is a bug in aiohttp that disables the re-use
# of the connection in the pool when method=HEAD.
# See: https://github.com/aio-libs/aiohttp/issues/1769
is_head = False
if method == "HEAD":
method = "GET"
is_head = True

# Top-tier tip-toeing happening here. Basically
Expand Down Expand Up @@ -221,9 +217,9 @@ async def perform_request(
timeout=timeout,
fingerprint=self.ssl_assert_fingerprint,
) as response:
if is_head: # We actually called 'GET' so throw away the data.
if is_head:
await response.release()
raw_data = ""
raw_data = "" # HEAD method has no response body

Check warning on line 222 in opensearchpy/connection/http_async.py

View check run for this annotation

Codecov / codecov/patch

opensearchpy/connection/http_async.py#L222

Added line #L222 was not covered by tests
else:
raw_data = await response.text()
duration = self.loop.time() - start
Expand Down

0 comments on commit 9560795

Please sign in to comment.