Fix #76342: file_get_contents waits twice specified timeout #4486
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Currently, if getting the response headers fails, we are still trying to read past them to get the content. Is that logical? 🤔
That's the cause of the fixed bug : the current behavior makes 2 call to
php_stream_get_line
, thus "applying" 2 times the timeout. I guess that in the particular described setup, the end of stream is not detected. However, the timeout being applied 2 times is not coherent at all.I just moved the
/* read past HTTP headers */
code block so it is executed only if getting the headers was successful. We can also fix it by forcing$stream->eof = 1;
when the first call fails but I guess that's dirtier.I know close to nothing about C and PHP source code but at least the test can be used if it can be fixed in a better way 😄