Skip to content

RedirectPlugin: Default to empty path when Location doesn't specify any #218

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

Merged
merged 1 commit into from
Sep 21, 2022

Conversation

ostrolucky
Copy link
Contributor

Q A
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Related tickets fixes #217
Documentation
License MIT

@@ -244,22 +249,6 @@ private function createUri(ResponseInterface $redirectResponse, RequestInterface
$uri = $uri->withPort($parsedLocation['port']);
Copy link
Contributor

Choose a reason for hiding this comment

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

i am actually not sure about this one either. if i was on http://localhost:8080/foo and i get redirect a header https://php-http.org/bar i would not expect to stay on port 8080... the only case where the port should be kept is when there is also no host in the redirection... wdyt?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree. Will change

@dbu
Copy link
Contributor

dbu commented Sep 12, 2022

thanks for looking into this! i think you are right that we need to also reset the path if none is provided, and i like how you compact the code by chaining the calls.

can you please check the test failure? is this some mocking going wrong? could we use an actual URI implementation instead of mocking, if thats the cause for the issue?

@ostrolucky
Copy link
Contributor Author

ostrolucky commented Sep 12, 2022

Wow those phpspec tests are insane. Can I just delete those phpspec tests I have trouble with, since I replaced it with integration-like new phpunit test? Otherwise it would take me entire day to fix it, as phpspcec is makint it very difficult to find what needs to be changed.

Edit: I'll try to give it more chance and perhaps replace some parts of mocks with real stuff like you suggested first

@dbu
Copy link
Contributor

dbu commented Sep 13, 2022

i guess the problem is that the Uri object is mocked instead of using an actual implementation, and it is missing mocking those calls. but i agree to remove the failing cases in favor of the phpunit tests, i also find them a lot more readable. please add a phpdoc to the top of the RedirectPluginSpec that mentions the phpunit test and vice versa.

@dbu
Copy link
Contributor

dbu commented Sep 16, 2022

@ostrolucky do you remove the failing phpspec tests and also fix the thing about the port?

@ostrolucky
Copy link
Contributor Author

Yes I just didn't have time to continue since my last struggle, but I have unstaged changes

@ostrolucky
Copy link
Contributor Author

Should be addressed now.

@ostrolucky ostrolucky force-pushed the fix-redirect-plugin-path-handling branch 2 times, most recently from 860464a to 5bb0f5a Compare September 20, 2022 19:11
@dbu dbu mentioned this pull request Sep 21, 2022
@dbu
Copy link
Contributor

dbu commented Sep 21, 2022

i fixed the build issue in #220, can you please rebase this branch on master? i don't expect problems with only one symfony version, but it just feels too yolo to merge a PR with failing builds :-)

@ostrolucky ostrolucky force-pushed the fix-redirect-plugin-path-handling branch from 5bb0f5a to c06f154 Compare September 21, 2022 08:43
@ostrolucky
Copy link
Contributor Author

rebased

@dbu dbu merged commit 76730e3 into php-http:master Sep 21, 2022
@dbu
Copy link
Contributor

dbu commented Sep 21, 2022

yay, thanks!

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.

RedirectPlugin is wrongly overwriting path and falsely detects circular redirect
2 participants