This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
symfony/src/Symfony/Component/BrowserKit
Fabien Potencier da6f190a6b merged branch tiraeth/master-browserkit-redirect (PR #8025)
This PR was squashed before being merged into the master branch (closes #8025).

Discussion
----------

[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.

Commits
-------

8f54da7 [BrowserKit] should not follow redirects if status code is not 30x
2013-05-15 17:16:47 +02:00
..
Tests [BrowserKit] should not follow redirects if status code is not 30x 2013-05-15 17:16:46 +02:00
.gitignore made usage of Composer autoloader for subtree-split unit tests 2012-11-09 14:10:06 +01:00
CHANGELOG.md [BrowserKit] should not follow redirects if status code is not 30x 2013-05-15 17:16:46 +02:00
Client.php [BrowserKit] should not follow redirects if status code is not 30x 2013-05-15 17:16:46 +02:00
composer.json removed versions in composer.json files 2013-05-13 16:36:40 +02:00
Cookie.php Merge branch '2.1' into 2.2 2013-04-20 21:05:29 +02:00
CookieJar.php Merge branch '2.1' into 2.2 2013-04-30 09:15:50 +02:00
History.php replaced symfony-project.org by symfony.com 2011-03-06 12:40:06 +01:00
LICENSE updated license year 2013-01-04 17:59:43 +01:00
phpunit.xml.dist made usage of Composer autoloader for subtree-split unit tests 2012-11-09 14:10:06 +01:00
README.md made usage of Composer autoloader for subtree-split unit tests 2012-11-09 14:10:06 +01:00
Request.php CS Fixes - Replaced "array of type" by "Type[]" in PHPDoc block 2012-11-19 13:58:52 +01:00
Response.php [BrowserKit] tagged the guaranteed BC API 2011-03-24 09:25:46 +01:00

BrowserKit Component

BrowserKit simulates the behavior of a web browser.

The component only provide an abstract client and does not provide any "default" backend for the HTTP layer.

Resources

For a simple implementation of a browser based on an HTTP layer, have a look at Goutte.

For an implementation based on HttpKernelInterface, have a look at the Client provided by the HttpKernel component.

You can run the unit tests with the following command:

$ cd path/to/Symfony/Component/BrowserKit/
$ composer.phar install --dev
$ phpunit