Closed gentsir closed 2 years ago
Thank you for reporting.
the second parameter $value can set to int type in the CodeIgniter\HTTP\Header constructor.
Why? HTTP header values are all string.
This is off topic, but v4.1.1 has serious security bugs. We recommend upgrade. See https://github.com/codeigniter4/CodeIgniter4/security/advisories
@gentsir It seems your sample code does not work.
Do you mean the headers
element in the third parameter $options
of CURLRequest::request()
?
$client->request('get', '/', [
'headers' => [
'User-Agent' => 'testing/1.0',
'Accept' => 'application/json',
'X-Foo' => ['Bar', 'Baz'],
],
]);
https://codeigniter4.github.io/CodeIgniter4/libraries/curlrequest.html#headers
@kenjis
sorry, I have edited the sample code again.
I checked and found that the CodeIgniter\HTTP\Header::getValueLine method was causing the problem by converting the int header value to an empty string.
Adding additional check is_numeric
to the above method should fix the issue, but the problem is more complicated.
In general Header
class accepts only array|string|null
: https://github.com/codeigniter4/CodeIgniter4/blob/develop/system/HTTP/Header.php#L81
So the question is:
Header
class creation to strings (I guess we should then also cast numeric values in arrays - just for consistency)The property $value
in Header
is array|string
.
Having int
is a bug.
PHP Version
7.3
CodeIgniter4 Version
4.1.1
CodeIgniter4 Installation Method
Manual (zip or tar.gz)
Which operating systems have you tested for this bug?
Windows, Linux
Which server did you use?
fpm-fcgi
Database
MySQL 5.6
What happened?
when i set some headers options to call
CURLRequest::request
method,i found that the int type value is filtered. the last version also has this issue.Steps to Reproduce
the headers option:
the debug output:
Expected Output
the second parameter $value can set to int type in the CodeIgniter\HTTP\Header constructor.
Anything else?
No response