Symfony - How to obtain POST parameter after redirect from HTTPS to HTTP
I have a symfony project where the user can search for products. This works fine while searching from an unsecured module. E.g. the landing page.
Now when the user is logged in, looking at his profile settings, I use a https connection. My problem is that when I search for anything, I get redirected to the http version and while doing that my POST parameters are lost and the search won't work.
This is the part of the log when searching over http:
[info] {sfFilterChain} Executing filter "sfRenderingFilter"
[info] {sfFilterChain} Executing filter "sslFilter"
[info] {sfFilterChain} Executing filter "sfExecutionFilter"
This is how it looks like when searching from an https secured site:
[info] {sfFilterChain} Executing filter "sfRenderingFilter"
[info] {sfFilterChain} Executing filter "sslFilter"
[info] {sfFrontWebController} Redirect to "http://project.localhost/search"
[info] {sfWebResponse} Send status "HTTP/1.1 301 Moved Permanently"
[info] {sfWebResponse} Send header "Location: http://project.localhost/search"
...
[info] {sfFilterChain} Executing filter "sfExecutionFilter"
The problem is that my sslFilter does not keep the original post parameters!
This is the code inside my execute($filterChain) where I change from https to http. How can I keep the POST parameters.
if ($redirect) {
$non_secure_url = str_replace('https', 'http', $request->getUri());
return $context->getController()->redirect($non_secure_url, 0, 301);
}
$filterChain->execute();
I tried various thing like described in here: retaining POST parameter开发者_StackOverflow社区s after login page in symfony
But there they save the parameter in the user and not in the response. I need them in the POST parameter array.
I think that what you want to do is not really possible, due to the nature of http.
But you can certainly imagine a workaround.
based ont he post that you've cited :
$user->setAttribute('param_name', $request->getParameter('post_data'));
set user attribute post_data
And after in your action you can "construct" $_Post array:
$_POST['test'] = $this->getUse()->getAttribute('post_data');
or use sfRequest::setParameter()
精彩评论