codeigniter4 / CodeIgniter4

Open Source PHP Framework (originally from EllisLab)
https://codeigniter.com/
MIT License
5.4k stars 1.9k forks source link

Bug: CURLRequest unable to set body in options. #6840

Closed gixxy22 closed 2 years ago

gixxy22 commented 2 years ago

PHP Version

8.1

CodeIgniter4 Version

4.2.10

CodeIgniter4 Installation Method

Composer (using codeigniter4/appstarter)

Which operating systems have you tested for this bug?

Linux

Which server did you use?

fpm-fcgi

Database

MariaDB 10.6.11

What happened?

From the docs: https://codeigniter4.github.io/CodeIgniter4/libraries/curlrequest.html#body

This works: $client->setBody($body)->request('put', 'http://example.com'); This doesn't:$client->request('put', 'http://example.com', ['body' => $body]);

The latter doesn't seem to set the body and the request sends empty content.

Steps to Reproduce

Create a simple CURL request and try to send data in the body using the options parameter, when debugging enabled, you can see the Content-Length is set to 0.

Expected Output

Expect the request to send the data in the body.

Anything else?

No response

datamweb commented 2 years ago

Hello, with the following change

$client->request('PUT', 'http://example.com', [
   'body' => $body,
   'http_errors' => false,
   'debug' => true,
]);

What are the contents of file log?

kenjis commented 2 years ago

This bug has been fixed in develop. Please try if you can.