-
Notifications
You must be signed in to change notification settings - Fork 50
Allow to disable body limitation size #322
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
Conversation
Thanks, LGTM, |
I've created the documentation PR, and update this PR description. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i am not sure if this is a good idea. you could set the limit to 100k or whatever crazy high value. removing the limit could break in bad ways when you ever happen to load several megabyte of data. then again, the way FullHttpMessageFormatter is implemented, the whole body is converted to string anyways.
i am +0 on this. if the other maintainers like it i won't oppose merging it. however, if we want to do this, we have to adjust the constructor of FullHttpMessageFormatter so that this not only works accidentally but is explicit.
when we move php-http/message to PHP 7.1+, we will do strict type declarations and atm, the $maxBodyLength would then be forced to int
. you'd need to adjust the phpdoc on the parameter and on the property to int|null
. we should also adjust addBody to handle null explicitly, even though it accidentally works because mb_substr($string, 0, null) takes the whole string.
Sure, it could be dangerous. But when I use the Symfony profiler (in dev mode), I don't want that my body content will be truncate. In a debug purpose, I want to have all information I need. I'm going to open a new PR in the |
…body_length is not an integer or null
i just changed the code that you will adjust, please check the newest master: php-http/message#111 |
👍 |
@dbu I think there is some cases where it's useful, specially when uou know that the remote api will never throw a too big response. As an example when using a client for elasticsearch, i know that i will never get a too big output, and that i can always show the the full body, (but i often hit the default limit here). |
apart from that i am okay to merge this as soon as we have the merge request against php-http/message to state that |
thanks for this contribution (and your patience while we figured out how to exactly do this ;-) ) |
No problem 😄 |
} | ||
|
||
if (!is_int($maxLength)) { | ||
$invalidConfiguration = new InvalidConfigurationException('The child node "captured_body_length" at path "httplug.profiling" must be an integer or null.'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for being late, but wouldn't it be more straight-forward to use something like ifTrue(...)->thenInvalid()
construct?
What I have in mind would be something like this:
->scalarNode('captured_body_length')
->validate()
->ifTrue(function ($v) {
return null !== $v && !is_int($v);
})
->thenInvalid('The child node "captured_body_length" at path "httplug.profiling" must be an integer or null ("%s" given).')
->end()
->end()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
agreed. i created #323 with your proposed change
What's in this PR?
This PR allow to set the
httpplug.profiling.captured_body_length
toNULL
to avoid body truncate in the Symfony profiler.Why?
I want to view all the body content of a
Request
orResponse
.Checklist
To Do