-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug: prototype of setBody($data); method in CodeIgniter\HTTP\Message should be changed to setBody(string $data); #2466
Comments
I believe it's perfectly valid to set an array or object as the body of a Response (which extends Message) so the suggested change would cause issues elsewhere. Please provide enough details to recreate the issue that you're having. |
I was using an internally developed package . That package was setting body
as an array. Now I called getJSON() on the incoming request which perform
json_decode on the body. That returned an error that argument to
json_decode should be string.
…On Thu, 2 Jan 2020, 11:24 Lonnie Ezell, ***@***.***> wrote:
I believe it's perfectly valid to set an array or object as the body of a
Response (which extends Message) so the suggested change would cause issues
elsewhere.
Please provide enough details to recreate the issue that you're having.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#2466?email_source=notifications&email_token=ADLLWJTLZIEWHWGJUA43YBLQ3V6QVA5CNFSM4KAJ77V2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEH5WNZI#issuecomment-570124005>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ADLLWJV6P2AQTNXEDBRRNXDQ3V6QVANCNFSM4KAJ77VQ>
.
|
I'm a bit confused here. The You said you have problems with setting a value in the Message body. How does this have anything to do with |
Yes I am using in a way that is not intended. I should pass string but I
pass array . But there should be a type hinting. The body of a request is
always a string. So the param should be of string type. And that way I
should not be able to use it in a way not intended.
…On Mon, 13 Jan 2020, 09:32 Lonnie Ezell, ***@***.***> wrote:
I'm a bit confused here. The IncomingRequest's getJSON is intended to
retrieve the HTTP request's body and parse it as JSON. That will always be
a string after going through a web server, I believe.
You said you have problems with setting a value in the Message body. How
does this have anything to do with IncomginRequest? It sounds like you
might be using it a way it's not intended for.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#2466?email_source=notifications&email_token=ADLLWJT54UX3SBG6VH33YITQ5PRUJA5CNFSM4KAJ77V2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEIXOW3I#issuecomment-573500269>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ADLLWJVNM5Y3Y3ZAINU5TDDQ5PRUJANCNFSM4KAJ77VQ>
.
|
We have at least one test that explicitly uses
I think the type needs to remain undefined, but I will update the header variable type so it doesn't specify |
Describe the bug
prototype of
setBody($data);
method inCodeIgniter\HTTP\Message
should be changed tosetBody(string $data);
as when callingIncomingRequest::getJson()
the method finds something other string and tries to json decode it.CodeIgniter 4 version
v4.0.0-rc.3
Affected module(s)
All request modules.
Expected behavior, and steps to reproduce if appropriate
CodeIgniter\HTTP\Message::setBody should throw an error if anything other than
string
is passed.Context
The text was updated successfully, but these errors were encountered: