Skip to content

Remove useless code and fix double headers overwriting #48

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

Merged
merged 5 commits into from
Dec 7, 2016

Conversation

dzubchik
Copy link
Contributor

No description provided.

@dzubchik dzubchik changed the title This should fix #47 This should fix https://github.com/php-pm/php-pm-httpkernel/issues/47 Nov 17, 2016
@@ -10,6 +10,7 @@
use React\Http\Request as ReactRequest;
use Symfony\Component\HttpFoundation\Cookie;
use Symfony\Component\HttpFoundation\Request as SymfonyRequest;
use Symfony\Component\HttpFoundation\Request;
Copy link
Contributor

Choose a reason for hiding this comment

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

You have the SymfonyRequest already?

$_SERVER['PHP_AUTH_USER'] = '';
$_SERVER['PHP_AUTH_PW'] = '';
$_SERVER['AUTH_TYPE'] = '';
unset($headers['PHP_AUTH_USER'], $headers['PHP_AUTH_PW'], $headers['AUTH_TYPE']);
Copy link
Contributor

Choose a reason for hiding this comment

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

Are these guaranteed to be set or will array access throw a warning?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

$_SERVER['AUTH_TYPE'] = $type;
$headers['PHP_AUTH_USER'] = isset($credentialsParts[0]) ? $credentialsParts[0] : '';
$headers['PHP_AUTH_PW'] = isset($credentialsParts[1]) ? $credentialsParts[1] : '';
$headers['AUTH_TYPE'] = $type;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This would be an addon: what about Bearer authentication? It is today in symfony only available from the apache headers. Any idea how to get those across?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe we can use ServerBag to handle authorization headers?

@dzubchik
Copy link
Contributor Author

@andig, @marcj what do you think about implementing better headers parser in react/http? Or we should reset $_SERVER values in each request?

@dzubchik
Copy link
Contributor Author

dzubchik commented Dec 6, 2016

@marcj, @andig , I have a little updated this PR after seeing this commit. Now it works correctly with headers and auth headers parsing is moving to symfony request. I removed line with headers merging, because I could not find any example when symfony and react headers could be different. If you insist, I will return that line. But all my previous code should be removed from this adapter.

@@ -177,10 +157,10 @@ protected function mapRequest(ReactRequest $reactRequest)
$class = '\Symfony\Component\HttpFoundation\Request';
}

$syRequest = new $class($query, $post, $attributes = [], $cookies, $files, $_SERVER, $reactRequest->getBody());
/** @var SymfonyRequest $syRequest */
$syRequest = new $class($query, $post, $attributes = [], $_COOKIE, $files, $_SERVER, $reactRequest->getBody());
Copy link
Member

Choose a reason for hiding this comment

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

so you user and password in the symfony request with this change?

Copy link
Contributor

Choose a reason for hiding this comment

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

Would it be possiblr to create a new, clean pr and describe the problem it tries to solve? Must say that I'm totally lost by now.

@dzubchik dzubchik changed the title This should fix https://github.com/php-pm/php-pm-httpkernel/issues/47 Remove useless code and fix double headers overwriting Dec 7, 2016
@dzubchik
Copy link
Contributor Author

dzubchik commented Dec 7, 2016

First, I've created PR #46 because headers from react request rewrite all headers from symfony request. Then, I've opened the first version of this PR, because of bug when during application runtime $ _SERVER is just increasing overtime, so the headers are not consistant with current request. But, @marcj had fixed this in php-pm/php-pm@9b63b99, so I've rewrote my PR, only to remove my old code with auth headers, because now Symfony request handle all of this correctly and remove $ cookie, because it is useless.

@marcj
Copy link
Member

marcj commented Dec 7, 2016

@dzubchik thanks, good job!

@marcj marcj merged commit 7d24719 into php-pm:master Dec 7, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants