php-http / message

HTTP Message related tools
http://php-http.org
MIT License
1.29k stars 41 forks source link

CurlFormatter fails on large boddies #93

Closed Nyholm closed 6 years ago

Nyholm commented 6 years ago
Q A
Bug? yes
New Feature? no
Version Master

Actual Behavior

When posting super large bodies you will get an error because escshellargs does not allow more than X chars. https://github.com/php-http/message/blob/v1.4.1/src/Formatter/CurlCommandFormatter.php#L42

We should make sure to catch/suppress that error and write a better error message in the curl string.

llaakkkk commented 6 years ago

I will do it)

Nyholm commented 6 years ago

I've also noticed the following error:

Fatal error: escapeshellarg(): Input string contains NULL bytes

I know it occurs when I upload a binary file. Im probably doing something wrong but the cUrl formatter is not the right place to complain about this. We should make sure to catch this as well.

GaryPEGEOT commented 5 years ago

Hi ! Still got the issue on PHP 7.3 with php-http/message 1.7.2 :

Error: escapeshellarg(): Argument exceeds the allowed length of 8192 bytes
in CurlCommandFormatter.php line 48

Maybe something like:

 if (preg_match('/[\x00-\x1F\x7F]/', $data) || mb_strlen($data) > $theAllowedLength) {
    $data = '[binary stream omitted]';
}

would do the trick, or wrap it in a try catch. Anyone know how to get the limit for the function?