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 to send empty body, and consume it #522

Merged
merged 10 commits into from
Nov 12, 2022

Conversation

daddykotex
Copy link
Contributor

@daddykotex daddykotex commented Oct 17, 2022

Closes #515

I've decided to include a e2e test for ember because when fixed on both, client and server, the test is not flaky and I think its a long term win.

Equipped with http4s/http4s#4935 (comment), I implemented both the server fix and the client fix

@@ -102,7 +103,7 @@ private[smithy4s] class SmithyHttp4sClientEndpointImpl[F[_], Op[_, _, _, _, _],
val baseRequest = Request[F](method, uri, headers = headers)
if (inputHasBody) {
baseRequest.withEntity(input)
} else baseRequest
} else baseRequest.withEntity(ByteVector.empty)
Copy link
Contributor

@ahjohannessen ahjohannessen Oct 17, 2022

Choose a reason for hiding this comment

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

Should this not only apply to methods like PUT and POST?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

that's a good question, let me see what facilities exists here to distinguish what method allow or not bodies

Copy link
Contributor

@ahjohannessen ahjohannessen Oct 17, 2022

Choose a reason for hiding this comment

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

This is in ember:

  private val NoPayloadMethods: Set[Method] =
    Set(Method.GET, Method.DELETE, Method.CONNECT, Method.TRACE)

Noticed that here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it annoys me that I can't find a public equivalent for this and avoid copy/pasting that method Set out of ember :/

Copy link
Contributor

@armanbilge armanbilge Oct 18, 2022

Choose a reason for hiding this comment

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

.putHeaders(`Content-Length`.zero) might be another workaround. And I think this is ok for GET requests. IDK YMMV.

Copy link
Contributor

Choose a reason for hiding this comment

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

it annoys me that I can't find a public equivalent for this and avoid copy/pasting that method Set out of ember :/

Ah yeah, an issue or PR to fix this would be great. Seems like we just need to add a boolean to Method.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

happy to open it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Following the discussions in the PR, I think this should be merged as in. I'm not sure there can be an always accurate way of telling whether a particular method should have a body or not.

Considering it works for our current use cases, we should move forward with it. If we get and issue later on that sending and empty body is problematic under certain situation, we should revisit.

.toResource
.flatMap(port =>
Port
.fromInt(port)
Copy link
Member

Choose a reason for hiding this comment

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

haven't checked but wouldn't you be able to bind to 0 and get a random port? except in this case you'd have a guarantee that it's free (again, not sure if ember behaves like this)

@daddykotex daddykotex changed the base branch from main to series/0.17 November 3, 2022 17:41
@daddykotex daddykotex force-pushed the dfrancoeur/515-client-empty-test branch from 9b25f42 to b699d7a Compare November 3, 2022 18:05
@daddykotex
Copy link
Contributor Author

I've rebased on top of series/0.17 rather than trying to reconcile the two branches

But I think the code in series/0.17 is somewhat problematic, in the sense, that my local githooks were failing for copyright notices missing on some generated files

we should update the ci so that PR to 0.17 can trigger a CI run

@Baccata
Copy link
Contributor

Baccata commented Nov 4, 2022

@daddykotex I've fixed it in my PR, you can apply the same change to ci.yml (glob pattern problem) to get it running.

@daddykotex
Copy link
Contributor Author

I think I'll mark as draft and marge series/0.17 in this branch when #567 is merged

@daddykotex daddykotex marked this pull request as draft November 4, 2022 14:53
@Baccata
Copy link
Contributor

Baccata commented Nov 10, 2022

@daddykotex I think it's time to sync this and tag it ready

@daddykotex daddykotex marked this pull request as ready for review November 10, 2022 18:17
@Baccata Baccata merged commit 9eb2a01 into series/0.17 Nov 12, 2022
@Baccata Baccata deleted the dfrancoeur/515-client-empty-test branch November 12, 2022 11:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

java.io.IOException: Broken pipe occurring on client calls with empty bodies
5 participants