-
Notifications
You must be signed in to change notification settings - Fork 70
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
Changes from 3 commits
3b6b017
0dc095d
ba80437
357b66a
6c3d37d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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; | ||
use Symfony\Component\HttpFoundation\Response as SymfonyResponse; | ||
use Symfony\Component\HttpFoundation\StreamedResponse as SymfonyStreamedResponse; | ||
use Symfony\Component\HttpKernel\TerminableInterface; | ||
|
@@ -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']); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
||
if (isset($headers['Authorization'])) { | ||
$authorizationHeader = $headers['Authorization']; | ||
|
@@ -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; | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe we can use ServerBag to handle authorization headers? |
||
} | ||
|
||
|
@@ -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; | ||
} | ||
|
There was a problem hiding this comment.
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?