Skip to content

Commit 7d24719

Browse files
dzubchikmarcj
authored andcommitted
Remove useless code and fix double headers overwriting (#48)
* Move data to appropriate superglobal * Remove unused import * Fix bug in basic auth * Update phpdoc * Remove auth headers parsing because of moving this to symfony request
1 parent 4fe3ead commit 7d24719

File tree

1 file changed

+2
-22
lines changed

1 file changed

+2
-22
lines changed

Bridges/HttpKernel.php

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ public function bootstrap($appBootstrap, $appenv, $debug)
4848
$appBootstrap = $this->normalizeAppBootstrap($appBootstrap);
4949

5050
$this->bootstrap = new $appBootstrap($appenv, $debug);
51-
5251
if ($this->bootstrap instanceof BootstrapInterface) {
5352
$this->application = $this->bootstrap->getApplication();
5453
}
@@ -124,7 +123,6 @@ protected function mapRequest(ReactRequest $reactRequest)
124123
$headers = $reactRequest->getHeaders();
125124
$query = $reactRequest->getQuery();
126125

127-
$cookies = [];
128126
$_COOKIE = [];
129127

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

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

153-
$_SERVER['PHP_AUTH_USER'] = '';
154-
$_SERVER['PHP_AUTH_PW'] = '';
155-
$_SERVER['AUTH_TYPE'] = '';
156-
157-
if (isset($headers['Authorization'])) {
158-
$authorizationHeader = $headers['Authorization'];
159-
$authorizationHeaderParts = explode(' ', $authorizationHeader);
160-
$type = $authorizationHeaderParts[0];
161-
if (($type === 'Basic' || $type === 'Digest') && isset($authorizationHeaderParts[1])) {
162-
$credentials = base64_decode($authorizationHeaderParts[1]);
163-
$credentialsParts = explode(':', $credentials);
164-
$_SERVER['PHP_AUTH_USER'] = isset($credentialsParts[0]) ? $credentialsParts[0] : '';
165-
$_SERVER['PHP_AUTH_PW'] = isset($credentialsParts[1]) ? $credentialsParts[1] : '';
166-
$_SERVER['AUTH_TYPE'] = $type;
167-
}
168-
}
169-
170150
$files = $reactRequest->getFiles();
171151
$post = $reactRequest->getPost();
172152

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

180-
$syRequest = new $class($query, $post, $attributes = [], $cookies, $files, $_SERVER, $reactRequest->getBody());
160+
/** @var SymfonyRequest $syRequest */
161+
$syRequest = new $class($query, $post, $attributes = [], $_COOKIE, $files, $_SERVER, $reactRequest->getBody());
181162

182163
$syRequest->setMethod($method);
183-
$syRequest->headers->add($headers);
184164

185165
return $syRequest;
186166
}

0 commit comments

Comments
 (0)