You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As a consequence there is no way to limit the length of what you want to copy without allocating a buffer that size. So for example, if you want to limit size of a file you're downloading to 1GB, but typical responses you expect are only a few KB, you still allocate the entire GB of memory each time.
Instead I think there should be a way to pass a maxlen and still get the dynamically growing buffer behavior using chunks of PHP_STREAM_COPY_ALL. Userland functions impacted are for example stream_get_contents or file_get_contents.