Tuesday, March 21, 2017

Post request missing payload

I'm building an api that receives incoming webhooks from external parties. Post requests to my application lack a body in some cases. In my logs I see the incoming request with the following header:

Accept:         */*
Content-Length: 
Content-Type:   application/json

As you can see the content-length is empty.

I cannot reproduce the problem. What I've tried thus far:

  • The request payload is only missing coming from a specific third party. If however, I provide this third party with a different callback url like request bin, the payload is not missing.

  • Connected this party source to our test environment. Which has exactly the same configuration (checked the entire php.ini) and the same version of our software. On our test server, requests are received with payload.

  • When sending post requests with Postman to our production environment, webhooks are received with payload.

  • Both test and production are https. I've tried sending http requests to our production server to see what happens, and I get an error as expected and no received headers in our logs.

  • Checked the php post_max_size, which is on 24M.

  • When creating a callback.php file in my public folder, and have the third party send it's webhooks to this destination, I am able to write the results to a log with the following code, which includes a payload. If I to output php://input later on in my Laravel application, it doesn't work:

    $postdata =  file_get_contents("php://input");
    $file     = fopen("webhook.log","w");
    echo fwrite($file,$postdata);
    fclose($file);
    
    

Both servers are running on the same php version (php7), and I am at a loss as to what to try next.



via wouthoekstra

Advertisement