Commit 02838458 authored by Dominik Hebeler's avatar Dominik Hebeler
Browse files

Wenn der PictureProxy ein Bild nicht abrufen kann, wirft er keinen Error mehr

parent 11650492
...@@ -17,19 +17,24 @@ class Pictureproxy extends Controller ...@@ -17,19 +17,24 @@ class Pictureproxy extends Controller
function get(Request $request) { function get(Request $request) {
if( $request->has('url') ) if( $request->has('url') )
{ {
$file = file_get_contents($request->input('url')); try{
$responseCode = explode(" ", $http_response_header[0])[1]; $file = file_get_contents($request->input('url'));
$contentType = ""; $responseCode = explode(" ", $http_response_header[0])[1];
foreach($http_response_header as $header) $contentType = "";
{ foreach($http_response_header as $header)
if( strpos($header, "Content-Type:") === 0)
{ {
$tmp = explode(": ", $header); if( strpos($header, "Content-Type:") === 0)
$contentType = $tmp[1]; {
$tmp = explode(": ", $header);
$contentType = $tmp[1];
}
} }
$response = Response::make($file, $responseCode);
$response->header('Content-Type', $contentType);
}catch(\ErrorException $e)
{
$response = Response::make("", 404);
} }
$response = Response::make($file, $responseCode);
$response->header('Content-Type', $contentType);
return $response; return $response;
} }
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment