Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX: Remove HEAD -> GET request swap workaround #699

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this is no longer needed as we only reuse it once, maybe just check the verb where it's needed?

if method == "HEAD":
method = "GET"
is_head = True

# Top-tier tip-toeing happening here. Basically
Expand Down Expand Up @@ -301,9 +297,9 @@
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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be None? There other other places where we assign things to "" where in fact we mean none I believe, too.

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 @@
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 @@
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
Loading