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

[HttpClient] Enable using EventSourceHttpClient::connect() for both GET and POST #51558

Merged
merged 1 commit into from
Sep 14, 2023

Conversation

wivaku
Copy link
Contributor

@wivaku wivaku commented Sep 4, 2023

Q A
Branch? 6.4
Bug fix? yes
New feature? no
Deprecations? no
License MIT

Fix so connect() can be used for SSE connections that require POST, e.g. GraphQL SSE subscriptions. This so we don't have to manually create the request() and include all of the options that are used for connect().

@carsonbot
Copy link

Hey!

I see that this is your first PR. That is great! Welcome!

Symfony has a contribution guide which I suggest you to read.

In short:

  • Always add tests
  • Keep backward compatibility (see https://symfony.com/bc).
  • Bug fixes must be submitted against the lowest maintained branch where they apply (see https://symfony.com/releases)
  • Features and deprecations must be submitted against the 6.4 branch.

Review the GitHub status checks of your pull request and try to solve the reported issues. If some tests are failing, try to see if they are failing because of this change.

When two Symfony core team members approve this change, it will be merged and you will become an official Symfony contributor!
If this PR is merged in a lower version branch, it will be merged up to all maintained branches within a few days.

I am going to sit back now and wait for the reviews.

Cheers!

Carsonbot

@derrabus
Copy link
Member

derrabus commented Sep 4, 2023

This looks like a new feature to me, especially since we need to change a method signature. Also, please note that we usually don't merge changes that are not covered by tests.

@derrabus derrabus modified the milestones: 6.3, 6.4 Sep 4, 2023
@derrabus derrabus changed the base branch from 6.3 to 6.4 September 4, 2023 22:39
@carsonbot carsonbot changed the title enable using connect() for both GET and POST [HttpClient] enable using connect() for both GET and POST Sep 4, 2023
@wivaku
Copy link
Contributor Author

wivaku commented Sep 5, 2023

What you say makes sense. Technically it's indeed not a bug. At the same time, was not sure it really deserved being called a feature.
As the change maintains backwards compatibility (before: always GET, after: optional argument that defaults to GET) and connect() is basically a wrapper to request() where both GET and POST are allowed, I was not sure if a test is needed.
My knowledge of the internals of the code is not sufficient to add a test.
Can someone help?

@stof
Copy link
Member

stof commented Sep 5, 2023

@wivaku we still need tests to cover the new feature you are adding (which is here to prevent regressing on it which would break it).

and anything that is not a bug fix is treated as a new feature going into the next minor version.
Btw, adding support for POST requests is definitely a new feature.

@wivaku
Copy link
Contributor Author

wivaku commented Sep 5, 2023

What both of you say makes sense. Technically it's indeed not a bug. At the same time, was not sure it really deserved being called a feature. POST was already allowed (using request) and connect is basically a wrapper that sets the headers for request.

As the change maintains backwards compatibility (before: always GET, after: optional argument that defaults to GET) and connect() is basically a wrapper to request() where both GET and POST are allowed, I was not sure if a test is needed. Totally fine if you feel it does need a test.

My knowledge of the internals of the code is not sufficient to add one though.
Can someone help?

@stof
Copy link
Member

stof commented Sep 5, 2023

@wivaku Add support for POST requests in `EventSourceHttpClient::connect()` is definitely describing a feature addition. And this is exactly what this PR does.
Btw, the changelog also needs to be updated.

And the rule is that anything that is not a bug fix goes into the next minor version. It is not about deserving being called a feature or no.

As the change maintains backwards compatibility (before: always GET, after: optional argument that defaults to GET) and connect() is basically a wrapper to request() where both GET and POST are allowed, I was not sure if a test is needed. Totally fine if you feel it does need a test.

The new test is not there to ensure this PR maintains backward compatibility (that's what the existing test ensure). It is there to ensure that *future PRs do not break the change you introduce in this one.
Without a test covering this feature, there is nothing preventing the support of POST requests to be broken by a future change (your own app would then become the CI reporting that this got broken, hopefully in your own CI if you have one or in production if it is not covered, but that would leave you with 1 month until the next patch release to get a fix being released...)

My knowledge of the internals of the code is not sufficient to add one though.

Look at the existing tests of the EventSourceHttpClient. The test for POST will be quite similar except that the mock will expect being called with a POST method.

@wivaku
Copy link
Contributor Author

wivaku commented Sep 5, 2023

Ok, attempted to add test. Similar to the GET test, but only checking the response, not the responseStream as this is already covered by the GET test.

All this, including Mockery tests are quite new to me, so apologies if I'm doing something wrong.

Because of my lack of experience the way I read the Mockery test is confusing to me: in the test I specify that the response will be for the method and then I test if the response I get is indeed that response.

Copy link
Member

@nicolas-grekas nicolas-grekas left a comment

Choose a reason for hiding this comment

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

Thanks for the PR. Please add a line to the changelog of the component about this.

@nicolas-grekas nicolas-grekas changed the title [HttpClient] enable using connect() for both GET and POST [HttpClient] Enable using EventSourceHttpClient::connect() for both GET and POST Sep 12, 2023
Copy link
Member

@nicolas-grekas nicolas-grekas left a comment

Choose a reason for hiding this comment

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

I fixed my review comments.

@nicolas-grekas
Copy link
Member

Thank you @wivaku.

@nicolas-grekas nicolas-grekas merged commit 7c833ee into symfony:6.4 Sep 14, 2023
7 of 8 checks passed
This was referenced Oct 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants