symfony/symfony — pull request #8025 by tiraeth (2013-05-13 13:50:11+00:00)
Title: [BrowserKit] should not follow redirects if status code is not 30x

| Q | A
| ------------- | ---
| Bug fix? | yes
| New feature? | no
| BC breaks? | yes
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | -
| License | MIT
| Doc PR | -

Currently, BrowserKit operates incorrectly. It follows "redirect" when `Location` header is present, but having just the header is not enough to perform redirection. [RFC-2616](http://tools.ietf.org/html/rfc2616#section-14.30) precisely says that the redirection should be performed only with `30x` status codes.

This PR fixes the incorrect behaviour of BrowserKit and make it consist with both the RFC document and with other clients, used for example with Behat.

I've found the issue while testing my application with Behat. I was returning `Location` header with `HTTP 201/Created` status code and was surprised that BrowserKit follows the redirection.

This PR is for 2.3 version (master) of Symfony. If you consider this issue as a bug (as I do), I can prepare PRs also for 2.1 and 2.2 branches. Meanwhile, I am leaving todo list below:

- [ ] create similar fix for 2.1 branch
- [ ] create similar fix for 2.2 branch