Fixed content type check for Gogs webhook. Issue #185.

This commit is contained in:
Dmitry Khomutov 2018-06-04 18:52:52 +07:00
parent ef4ebe14b4
commit b54af48bd7
No known key found for this signature in database
GPG key ID: EC19426474B37AAC

View file

@ -592,11 +592,11 @@ class WebhookController extends Controller
}
/**
* Called by Gogs Webhooks:
*
* @param string $projectId
*
* @return array
*
* @throws Exception
*/
public function gogs($projectId)
{
@ -606,14 +606,12 @@ class WebhookController extends Controller
]);
switch ($_SERVER['CONTENT_TYPE']) {
case 'application/json':
$payload = json_decode(file_get_contents('php://input'), true);
break;
case 'application/x-www-form-urlencoded':
$payload = json_decode($this->getParam('payload'), true);
break;
case 'application/json':
default:
return ['status' => 'failed', 'error' => 'Content type not supported.', 'responseCode' => 401];
$payload = json_decode(file_get_contents('php://input'), true);
}
// Handle Push web hooks: