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 all 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
24 changes: 2 additions & 22 deletions Bridges/HttpKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ public function bootstrap($appBootstrap, $appenv, $debug)
$appBootstrap = $this->normalizeAppBootstrap($appBootstrap);

$this->bootstrap = new $appBootstrap($appenv, $debug);

if ($this->bootstrap instanceof BootstrapInterface) {
$this->application = $this->bootstrap->getApplication();
}
Expand Down Expand Up @@ -124,7 +123,6 @@ protected function mapRequest(ReactRequest $reactRequest)
$headers = $reactRequest->getHeaders();
$query = $reactRequest->getQuery();

$cookies = [];
$_COOKIE = [];

$sessionCookieSet = false;
Expand All @@ -133,7 +131,6 @@ protected function mapRequest(ReactRequest $reactRequest)
$headersCookie = explode(';', isset($headers['Cookie']) ? $headers['Cookie'] : $headers['cookie']);
foreach ($headersCookie as $cookie) {
list($name, $value) = explode('=', trim($cookie));
$cookies[$name] = $value;
$_COOKIE[$name] = $value;

if ($name === session_name()) {
Expand All @@ -150,23 +147,6 @@ protected function mapRequest(ReactRequest $reactRequest)
session_id(Utils::generateSessionId());
}

$_SERVER['PHP_AUTH_USER'] = '';
$_SERVER['PHP_AUTH_PW'] = '';
$_SERVER['AUTH_TYPE'] = '';

if (isset($headers['Authorization'])) {
$authorizationHeader = $headers['Authorization'];
$authorizationHeaderParts = explode(' ', $authorizationHeader);
$type = $authorizationHeaderParts[0];
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;
}
}

$files = $reactRequest->getFiles();
$post = $reactRequest->getPost();

Expand All @@ -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.


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

return $syRequest;
}
Expand Down