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
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions Bridges/HttpKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -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?

use Symfony\Component\HttpFoundation\Response as SymfonyResponse;
use Symfony\Component\HttpFoundation\StreamedResponse as SymfonyStreamedResponse;
use Symfony\Component\HttpKernel\TerminableInterface;
Expand Down Expand Up @@ -150,9 +151,7 @@ protected function mapRequest(ReactRequest $reactRequest)
session_id(Utils::generateSessionId());
}

$_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.


if (isset($headers['Authorization'])) {
$authorizationHeader = $headers['Authorization'];
Expand All @@ -161,9 +160,9 @@ protected function mapRequest(ReactRequest $reactRequest)
if (($type === 'Basic' || $type === 'Digest') && isset($authorizationHeaderParts[1])) {
$credentials = base64_decode($authorizationHeaderParts[1]);
$credentialsParts = explode(':', $credentials);
$_SERVER['PHP_AUTH_USER'] = isset($credentialsParts[0]) ? $credentialsParts[0] : '';
$_SERVER['PHP_AUTH_PW'] = isset($credentialsParts[1]) ? $credentialsParts[1] : '';
$_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?

}

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

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

$syRequest->setMethod($method);
$syRequest->headers->add($headers);
$syRequest->headers->replace($headers);

return $syRequest;
}
Expand Down