Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[BrowserKit] Fixed server HTTP_HOST port uri conversion#11356

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed

Conversation

@bcremer
Copy link
Contributor

QA
Bug fix?yes
New feature?no
BC breaks?no
Deprecations?no
Tests pass?yes
Fixed ticketsn/a
LicenseMIT
Doc PRn/a

This will fix URI conversion using the HTTP_HOST server header.

Steps to reproduce:

$client = new TestClient();$server = array('HTTP_HOST' => 'example.com:8000');$client->request('GET', 'http://example.com:8000', [], [], $server);echo $client->getRequest()->getUri(); // outputs:  http://example.com:8000:8000// expected: http://example.com:8000

We discovered this issue duringmink testing usinggoutte on a non standard port.

@stof
Copy link
Member

stof commentedJul 9, 2014

The issue is that you specifyHTTP_HOST the wrong way. HTTP_HOST does not include the port in PHP. the port is inSERVER_PORT

@stof
Copy link
Member

stof commentedJul 9, 2014

hmm, actually, it does include it. It is SERVER_NAME which does not include it.

@bcremer
Copy link
ContributorAuthor

So this means thiscommit should be reverted?
This would also fix the problem for us.

We stumbled upon this error using goutte`s history functions:

$client = new \Goutte\Client();$client->request('GET', 'http://localhost:8080/a.html');$client->request('GET', 'http://localhost:8080/b.html');echo $client->getHistory()->current()->getServer()['HTTP_HOST'];// outputs  localhost:8080// this fails$client->back();

@bcremer
Copy link
ContributorAuthor

Any news here, or anything I can help to get this merged?

Copy link
Member

Choose a reason for hiding this comment

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

Can you remove the spaces around the dot?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Fixed.

@fabpot
Copy link
Member

👍

1 similar comment
@romainneutron
Copy link
Contributor

👍

Choose a reason for hiding this comment

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

a preg_quote is required aroundparse_url($uri, PHP_URL_HOST).$port, because:

var_dump(parse_url('abc.+def:9090',PHP_URL_HOST));string(8)"abc.+def"

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

@nicolas-grekas
I'm not sure if I can follow you.
You propose to change the code to:

if ($port = parse_url($uri, PHP_URL_PORT)) {    $port = ':'.$port;}$uri = preg_replace('{^(https?\://)'.preg_quote(parse_url($uri, PHP_URL_HOST).$port).'}', '${1}'.$server['HTTP_HOST'], $uri);

May you please provide me with a failing testcase like the following so I can verify the problem?

$client = new TestClient();$server = array('HTTP_HOST' => 'www.example.com:8000');$parameters = array();$files = array();$client->request('GET', 'http://example.com', $parameters, $files, $server);$this->assertEquals('http://www.example.com:8000', $client->getRequest()->getUri(), '->request() uses HTTP_HOST to add port');

@fabpot
Copy link
Member

Closing in favor of#11469

@fabpotfabpot closed thisJul 25, 2014
fabpot added a commit that referenced this pull requestJul 25, 2014
…cremer, fabpot)This PR was merged into the 2.3 branch.Discussion---------- [BrowserKit] Fixed server HTTP_HOST port uri conversion| Q             | A| ------------- | ---| Bug fix?      | yes| New feature?  | no| BC breaks?    | no| Deprecations? | no| Tests pass?   | yes| Fixed tickets |#11356| License       | MIT| Doc PR        | n/aSee#11356Commits-------103fd88 [BrowserKit] refactor code and fix unquoted regexf401ab9 Fixed server HTTP_HOST port uri conversion
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

5 participants

@bcremer@stof@fabpot@romainneutron@nicolas-grekas

[8]ページ先頭

©2009-2025 Movatter.jp