-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Fixed server values in BrowserKit #10549
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
Closed
Closed
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Member
fabpot
commented
Mar 27, 2014
Q | A |
---|---|
Bug fix? | yes |
New feature? | no |
BC breaks? | no |
Deprecations? | no |
Tests pass? | yes |
Fixed tickets | #9527, #9762, #9821, #9901 |
License | MIT |
Doc PR | n/a |
fabpot
added a commit
that referenced
this pull request
Mar 27, 2014
This PR was merged into the 2.3 branch. Discussion ---------- Fixed server values in BrowserKit | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #9527, #9762, #9821, #9901 | License | MIT | Doc PR | n/a Commits ------- 65b9810 fixed too greedy replacements d9cf28d fixed protocol-relative URLs 289da16 added override power to server parameters provided on request method
It looks like this introduced a bug when using a non-standard port (ie localhost:8080) - see #10078 The uri becomes Looks like it is only causing an issue when using I am looking into exactly where the issue is. |
fabpot
added a commit
that referenced
this pull request
Nov 26, 2018
This PR was merged into the 2.8 branch. Discussion ---------- [BrowserKit] fixed BC Break for HTTP_HOST header | Q | A | ------------- | --- | Branch? | 2.7, 2.8, 3.x, 4.x | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes/no | Fixed tickets | #22933 | License | MIT | Doc PR | n/a The situation well described in the original issue. I will add only: - #10549 - makes server parameters to take precedence over URI. - #16265 - partially revererts #10549. Makes server parameters do not affect URI. But this is only true for `Client::request()`. It is still possible to set host for URI by `Client::setServerParameters()` when URI is realative (see examples below). I propose a compromise solution: add to HTTP_HOST header power to override URI when it is relative. Proposed solution: - if the request URI is relative, then use the HTTP_HOST header passed to Client::request() to generate an absolute URI - if the request URI is absolute, then ignore the HTTP_HOST header (as it now works) - do the same with HTTPS server parameter Profit: - fix BC Break - the documentation will be correct - http://symfony.com/doc/2.8/routing/hostname_pattern.html#testing-your-controllers - https://symfony.com/doc/2.8/testing.html#testing-configuration Before: ``` $client->setServerParameters(['HTTP_HOST' => 'example.com']); $client->request('GET', '/'); $this->assertEquals('http://example.com/', $client->getRequest()->getUri()); $client->request('GET', '/', [], [], ['HTTP_HOST' => 'example.com']); $this->assertEquals('http://localhost/', $client->getRequest()->getUri()); ``` Fixed (see last line): ``` $client->setServerParameters(['HTTP_HOST' => 'example.com']); $client->request('GET', '/'); $this->assertEquals('http://example.com/', $client->getRequest()->getUri()); $client->request('GET', '/', [], [], ['HTTP_HOST' => 'example.com']); $this->assertEquals('http://example.com/', $client->getRequest()->getUri()); ``` Commits ------- 8c4a594 [BrowserKit] fixed BC Break for HTTP_HOST header; implemented same behaviour for HTTPS server parameter
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.