php - ErrorException: Warning: Header may not contain more than a single header, new line detected -


i having trouble redirecting after function sends emails! function is:

public function emailaction($emails, $url) {      foreach($emails $email)     {         $message = \swift_message::newinstance()             ->setsubject('updates in symfony blog')             ->setfrom(array('blog@symfonyblog.com' => 'symfony blog'))             ->setto($email["email"])             ->setbody(             $this->renderview(                 'newsblogbundle:default:email.txt.twig',                 array('url' => $url)             )         )         ;         $this->get('mailer')->send($message);     }      return $this->redirect($this->newpostaction());     //return $this->redirect($this->generateurl('newsblogbundle_homepage'));  } 

it sends emails ok, when redirecting, gives error:

errorexception: warning: header may not contain more single header, new line detected in c:\path\to\webroot\symfony\app\cache\dev\classes.php line 3899

  1. in c:\path\to\webroot\symfony\app\cache\dev\classes.php line 3899
  2. at errorhandler->handle('2', 'header may not contain more single header, new line detected', 'c:\path\to\webroot\symfony\app\cache\dev\classes.php', '3899', array('this' => object(redirectresponse), 'name' => 'location', 'values' => array('/app_dev.php/blog', object(responseheaderbag), ' redirecting /app_dev.php/blog redirecting /app_dev.php/blog. ', '1.0', '302', 'found', null), 'value' => object(responseheaderbag)))
  3. at header('location: cache-control: no-cache date: wed, 17 jul 2013 11:56:17 gmt location: /app_dev.php/blog ', false) in c:\path\to\webroot\symfony\app\cache\dev\classes.php line 3899
  4. at response->sendheaders() in c:\path\to\webroot\symfony\app\cache\dev\classes.php line 3914
  5. at response->send() in c:\path\to\webroot\symfony\web\app_dev.php line 27

while haven't changed "headers" (and don't know about!). app_dev.php is:

<?php  use symfony\component\httpfoundation\request;  if (isset($_server['http_client_ip'])     || isset($_server['http_x_forwarded_for'])     || !in_array(@$_server['remote_addr'], array('127.0.0.1', 'fe80::1', '::1')) ) {     header('http/1.0 403 forbidden');     exit('you not allowed access file. check '.basename(__file__).' more information.'); }  $loader = require_once __dir__.'/../app/bootstrap.php.cache'; require_once __dir__.'/../app/appkernel.php';  $kernel = new appkernel('dev', true); $kernel->loadclasscache(); request::enablehttpmethodparameteroverride(); $request = request::createfromglobals(); $response = $kernel->handle($request); $response->send(); $kernel->terminate($request, $response); 

i tried 2 different ways of redirecting both (through routing , directly calling controller) of give same error, whilst pages load if jusr type in url!

i have no idea error , how should fix it!

to detail, problem return value of $this->newpostaction(). usally it's response object. redirect expects uri/route, can sent client via location header. redirect client side turn around. can use ->forward('acmebundle:demo:index') forward internally controller action. in case url on client not changed.


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -