Default to raw response for curl

This commit is contained in:
Les De Ridder 2017-02-10 14:53:58 +01:00
父節點 7e49b37fb8
當前提交 06a85be7da
沒有發現已知的金鑰在資料庫的簽署中
GPG 金鑰 ID: 5EC132DFA85DB372
共有 1 個檔案被更改,包括 11 行新增2 行删除

查看文件

@ -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':