开发者

PHP, HTTP: Processing an after deployment hook - what is my basic mistake?

开发者 https://www.devze.com 2023-02-05 05:06 出处:网络
My repository provider (Beanstalk), enables me, in the deployment process, to trigger a \"web hook\" after each deployment. I.e., after each deployment, it\'ll send a post request to a URL provided by

My repository provider (Beanstalk), enables me, in the deployment process, to trigger a "web hook" after each deployment. I.e., after each deployment, it'll send a post request to a URL provided by me, with a JSON encoded information about the deployment.

If i wasn't clear enough, this http://help.beanstalkapp.com/kb/deployments/post-release-web-hooks-for-deployments is a short and clear explanation provided by my repository provider.

I'm trying开发者_如何学Python to write the script that will process this request. Actually, I'm not interested in the provided information about the deployment. All I need is to know that a deployment were done, and to perform some activity on my server (for example: to update the DB). And that what I did. I just wrote a script that, when triggered, updates the DB and generally does what it need to do on the server.

Now,

The repository provider refuses to receive the URL to my script as a processor of its hooks, because it says it's being responded with HTTP 400.

Why can this happen? How can I control the returned HTTP value? I've never had to take care of this during my normal programming.

When testing my hook-processor by directing a browser to it, I see that it's being successfully triggered, and does what it needs to do on the server side.

The whole project, including my hook-processor, is written in PHP + the Yii framework. The server is Apache.

I figure out, that my (complete?) lack of understanding of the HTTP protocol, is probably what creates the problem for me here.

Thank you

Gidi

EDIT: Adding here the (trivial) code that handles the hook. It has only side effects, no output. (If I do add an output, like "echo 'done';" nothing changes

    public function actionAfterDeployment ()
    {
        $rootPath = Yii::getPathOfAlias ('system').'/../..';
        $console = $rootPath."/crm/console.php";
        exec ("php $console onEachDeployment ".$_SERVER["SERVER_NAME"]);
    }


as per gidireich's comment

My application was throwing an HTTP exception, due to a wrong CSRF token - no token was supplied, and it's a post request, requiring in our system such a token. Thanks for everybody participating

0

精彩评论

暂无评论...
验证码 换一张
取 消