1

Ok, here is the thing: I'm configuring a new SOAP server, I've a way to test it, (provided by others, and works with the old servers), so I know the tester it's fine. To trace the problem I've made a test, put at the beginning of the index file some lines to know what happened, then I find that the Request Method when I use the test, is "POST", but also $raw_post_data and $_POST are empty. The PHP version used is 5.6.40. (I use PHP_fpm to run multiple versions) The variables_order string contains P, enable_post_data_reading is enabled, post_max_size is 2048M and also upload_max_filesize and the apache service has been restarted. I event checked to remove de .htaccess file to avoid redirects. But all I get is empty strings everywhere. The lines on the test (I'll promise will encapsulate the reading of 'php://input' when I get this working)

The test code:

<?php    
     $raw_post_data = file_get_contents('php://input');
     $logfile = fopen('path/to/log/file.log',"a");
     fputs($logfile, "request method: ".$_SERVER['REQUEST_METHOD'].PHP_EOL);
     foreach ($_POST as $key => $value){
          fputs($logfile, "{$key} = {$value}\r\n");
     }
     fputs($logfile, "request: ".$raw_post_data.PHP_EOL);
     fputs($lofgile, ' ****** '.PHP_EOL);
     fclose($logfile);

The lines above, with the same method to post in the older servers, in the new only get empty strings.

The input is a XML file with all the data of some activities, the file works fine in the older servers, so I know it's not something about codification, and some identification data.

Edit: I've tested it in PHP 7.4 but still the same problem (I'm using PHP-FPM with multiple PHP versions, so it's only matter of a change in the .htaccess to point the handler)

Tnt80
  • 43
  • 3
  • And what is your input? _POST_ can be a bit tricky depending on what data format you're sending I.e. JSON, form encoded, raw, ... – waterloomatt Sep 20 '21 at 12:02
  • @waterloomatt added details about the input, some identification data (user and password) and an XML file. – Tnt80 Sep 20 '21 at 12:06
  • _$raqw_post_data_ copy/paste error? Also, please turn on error reporting and report back any warnings/errors - https://stackoverflow.com/a/21429652/296555 – waterloomatt Sep 20 '21 at 12:09
  • 2
    _"The PHP version used is 5.6.40"_ - still? Why? – CBroe Sep 20 '21 at 12:14
  • 1
    It is important to turn on error reporting because it may be caused by server settings such as _max_input_vars_ which defaults to 1000. With error reporting turned on, you will see the warnings being thrown. Also, as previous comment mentions PHP 5.6 is obsolete and isn't supported any more. You really should be using 8+ now. – waterloomatt Sep 20 '21 at 12:18
  • @waterloomatt done, but still no clue, error logs are empty too. The main thing using 5.6.40 it's because the software I'm trying to run needs it, it's not mine, and has not time to update it. – Tnt80 Sep 20 '21 at 14:08

1 Answers1

0

I have the answer (thanks to waterloomat): the application (not mine, and don't have access to the code) was sending the data as multipart; so, when I tried to read it was impossible. I needed to develop a way to read it as that, and let me access the data.

     $inputstream = "";
     if (is_resource($input = fopen('php://input', 'rb')) === true)
        {
                while ((feof($input) !== true) && (($line = fgets($input)) !== false))
                {
                        $inputstream .= $line;
                }
                fclose($input);
        }
     else {
        return "Error opening data.";
     }
Adrian Mole
  • 49,934
  • 160
  • 51
  • 83
Tnt80
  • 43
  • 3