-
-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Changes the followRedirect information #3377
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
Conversation
it automatically. You can examine the response and force a redirection | ||
afterwards with the ``followRedirect()`` method:: | ||
When a request returns a redirect response, the client follows it | ||
automatically. You can prevent this by issuing the ``followRedirects()`` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd use API links here (same below):
:method:`Symfony\\Component\\HttpKernel\\Client::followRedirects`
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was following the style that was already there. I can change it if that's now the preferred style
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's always good to have the API link in the docs. Maybe no one noticed this the first time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in fact, this section (and article) is from 2011 (when the docs looked like this). The API links where added in 2012, so it did not exists when writing this.
The followRedirect() method has changed to automatically follow redirects. I've changed the documentation to reflect this and left a note on how to change it back to the way it used to work.
How does this look? |
👍 |
Hey Mike! I'm actually not sure this is correct, We'll it may be more complicated. See the original PR that made this change at #1257. So, the default Client (in the BrowserKit component) does follow redirects automatically. But in a Symfony framework functional test, we're actually using the FrameworkBundle Client, which extends the Client in HttpKernel. As you can see, it reverses that setting and sets it to not follow redirects. Are you seeing different behavior? And if so, do you have a case where the default is different or am I possibly missing something in the code? Thanks! |
Ah, that's really confusing! 😃 I was coming from the silex docs, they link to the symfony2 ones. I missed that symphony uses the FrameworkBundle Client while silex uses the BrowserKit component. I guess I went too deep in trying to fix the documentation! Is there a reason that the two methods work in opposite ways? |
Hey Mike! That makes more sense, and that is confusing! I don't remember/know why there is a difference. However, I did look at the Silex docs, and it looks like even there (by extending this class: https://github.com/fabpot/Silex/blob/master/src/Silex/WebTestCase.php#L14, via the docs: http://silex.sensiolabs.org/doc/testing.html#webtestcase), you should still end up using the Thanks! |
The only thing that I can see that might be different is that the SIlex docs say that you have to install the dependencies manually to use the Symfony WebTestCase. Then it says to add symfony/browser-kit in to the composer.json file. After digging a little deeper, it seems that It's a little convoluted, so it is. |
@mgriffin the BrowerKit Client doesn't set |
Hmm, that's right. But it does on my machine... Ah hah! It doesn't now, with version 2.4.1. But the silex docs say to use >=2.3,<2.4-dev. When I tried to use that, it installed 2.3 which does set I checked to see if using 2.4 works and for this problem it does. Time to go and see about changing toe silex docs, I guess. Thanks for all the help. |
But in 2.3 the |
@xabbuh Where does it do that? I've tried it a number of different ways. When I load If I then change composer.json to load I'm not sure what else to do here, but the functionality has definitely changed there. I'm happy I can work around it, but I wanted to make sure that no one else has to run in to the same problem. |
In 2.3 it was set to false here: https://github.com/symfony/symfony/blob/2.3/src/Symfony/Component/HttpKernel/Client.php#L49 |
Yes, and you can see the slight change between 2.3 and 2.4 (notice its positioning relative to the parent construct), though I can't think of how this would make a difference. https://github.com/symfony/symfony/blob/2.3/src/Symfony/Component/HttpKernel/Client.php#L49 In both cases, if you're using the Can anyone else spot why that would cause Silex to follow redirects by default? I think we're going to ultimately make no change to the docs, but I would love to know if we're missing anything on this :). Thanks! |
@weaverryan the behavior is only different for custom child classes overwriting I don't see why Silex would behave differently though |
I'm going to close this issue. As it's written, it is correct. There were possibly some subtle differences with Silex and different versions of Symfony (which further confuse this issue), but I don't see anything that's actually wrong with the docs. Though, we there's a clarifying point we can add to help, I'd be open to that :). Cheers! |
That's fair enough. I could never understand what I was doing differently, but I got it working in the end. If it crops up again, I'll re submit it 😈 😄 |
The followRedirect() method has changed to automatically follow redirects. I've changed the documentation to reflect this and left a note on how to change it back to the way it used to work.