0

I am currently writing a reverse proxy using Symfony (learning purposes)

I am currently able to get text files (HTML, CSS, JS...) but when I'm trying to proxify images, Symfony end up messing up the file.

Here is a compare of the two files, the left one is the file proxified by Symfony

As you can see, there is a whitespace added at the beginning of the file.

enter image description here

When I remove it in notepad++, the image is fine.

Here is my code (I verified, right before returning my response, there is no whitespace) :

$url = "http://10.224.116.191:80";

if(strlen($base64Url) != 0 && $base64Url != "/"){ //base64Url contains an URL
  $url .= explode(">>", base64_decode(strtr(ltrim($base64Url, "/"), '-_', '+/')))[1];
}

$proxy = new Proxy($url);
$proxy->createCurl();
$response = new Response();
for($i = 0; $i < count($proxy->__headers()); $i++){
  $response->headers->set(array_keys($proxy->__headers())[$i], array_values($proxy->__headers())[$i]);
}
$response->setContent($proxy->__tostring());    
return $response;

Proxy comes from http://php.net/manual/en/book.curl.php#90821 where I added headers.

Any reason why this whitespace is added ?

JeanneD4RK
  • 323
  • 1
  • 5
  • 19
  • 1
    Search for `?>` in your code base's php files, and remove them if they are the last thing in the file. – Yoshi Apr 20 '18 at 07:36
  • You god damn wizard. Had one in Utils\Proxy. How come this is messing everything up ? – JeanneD4RK Apr 20 '18 at 08:15
  • It was just a guess ;) For further info, have a look here: https://stackoverflow.com/questions/4410704/why-would-one-omit-the-close-tag – Yoshi Apr 20 '18 at 08:20

0 Answers0