Strange behavior with RestController on different servers

Hello flow developers!

I’ve got an issue with a implementation of the RestController on a single server.
Two instances of the same project were running without problems.

This issue is soveld jet, but we/I want to know what is wrong with the first approach.

To demonstrate what I’ve done is easy. This is the first approach:

class InstanceSetupController extends RestController {

	protected $defaultViewObjectName = 'TYPO3\\Flow\\Mvc\\View\\JsonView';

  	public function listAction() {
  	   $response[ "result" ] = 0;
	   echo  json_encode( $response );
	} // public function listAction

As I said: this works on two servers. Response is as expected: {"result":0}
On the 3rd server the response is {"re

This is independent from what I “echo”. A

echo "Hello world!";

Ends up in response Hell
(very funny!)

Always there are only 4 chars as output…

Following code works on all three systems:

  	public function listAction() {
  	   $response[ "result" ] = 0;
	} // public function listAction

Of course the second implementation is the better way.

My question now is:

why the first one works on two systems and not on the 3rd?

Any suggestions/hints/estimations???


Oh please don’t use echo :wink:

public function listAction() {
   $response[ "result" ] = 0;
   return  json_encode( $response );

With the echo, I think the content length of the HTTP response is wrong, and maybe the problematic server is behind a proxy and as a more strict configuration about HTTP response. Event worse (not tested, but the I think it’s the case), the echo will be before the header of the response so the HTTP response is even more broken.

Let echo where it live, in the past, a long time ago