From 06a85be7da8d83a83754d3bfba2301be66321c9c Mon Sep 17 00:00:00 2001 From: Les De Ridder Date: Fri, 10 Feb 2017 14:53:58 +0100 Subject: [PATCH] Default to raw response for curl --- app/Http/Controllers/PasteController.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/PasteController.php b/app/Http/Controllers/PasteController.php index 52cdc5e..a502158 100644 --- a/app/Http/Controllers/PasteController.php +++ b/app/Http/Controllers/PasteController.php @@ -50,7 +50,16 @@ class PasteController extends Controller public function view(Request $request, Paste $paste) { - $format = $request->input('format', 'html'); //TODO: Use HTTP content negotiation for the default format + //TODO: Use HTTP content negotiation for the default format + $userAgent = $request->header('User-Agent'); + if(substr($userAgent, 0, 4) == 'curl') + { + $format = $request->input('format', 'raw'); //default to raw format for curl + } + else + { + $format = $request->input('format', 'html'); //default to html format for other user agents + } switch($format) { @@ -59,7 +68,7 @@ class PasteController extends Controller case 'raw': return $this->view_raw($paste); case 'json': - return $this->view_json($paste); + return $this->view_json($paste); case 'latex': return $this->view_latex($paste); case 'png':