-
Couldn't load subscription status.
- Fork 8k
Fixed GH-10270 Unable to return CURL_READFUNC_PAUSE in readfunc callback #10607
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
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| --TEST-- | ||
| Test CURL_READFUNC_PAUSE and curl_pause() | ||
| --EXTENSIONS-- | ||
| curl | ||
| --FILE-- | ||
| <?php | ||
| include 'server.inc'; | ||
| $host = curl_cli_server_start(); | ||
|
|
||
| class Input { | ||
| private static $RESPONSES = [ | ||
| 'Foo bar ', | ||
| CURL_READFUNC_PAUSE, | ||
| 'baz qux', | ||
| null | ||
| ]; | ||
| private int $res = 0; | ||
| public function __invoke($ch, $hReadHandle, $iMaxOut) | ||
| { | ||
| return self::$RESPONSES[$this->res++]; | ||
| } | ||
| } | ||
|
|
||
| $inputHandle = fopen(__FILE__, 'r'); | ||
|
|
||
| $ch = curl_init(); | ||
| curl_setopt($ch, CURLOPT_URL, "{$host}/get.inc?test=input"); | ||
| curl_setopt($ch, CURLOPT_UPLOAD, 1); | ||
| curl_setopt($ch, CURLOPT_READFUNCTION, new Input); | ||
| curl_setopt($ch, CURLOPT_INFILE, $inputHandle); | ||
| curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); | ||
|
|
||
| $mh = curl_multi_init(); | ||
| curl_multi_add_handle($mh, $ch); | ||
| do { | ||
| $status = curl_multi_exec($mh, $active); | ||
| curl_pause($ch, CURLPAUSE_CONT); | ||
| if ($active) { | ||
| usleep(100); | ||
| curl_multi_select($mh); | ||
| } | ||
| } while ($active && $status == CURLM_OK); | ||
|
|
||
| echo curl_multi_getcontent($ch); | ||
| ?> | ||
| --EXPECT-- | ||
| string(15) "Foo bar baz qux" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
Uh oh!
There was an error while loading. Please reload this page.
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.
how difficult is it to add a test for the usage of
CURL_READFUNC_PAUSE? it would be nice to have one I guess unless it's very compilcatedThere 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 added one, that I know test the code, but what I don't like about it is that there is no way to know that the read is paused. But I guess it's better than nothing.
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.
Yeah, it's definitely better! Would it make sense to return
CURL_READFUNC_PAUSEuntil a specific amount of time elapses (e.g. 1 sec)? If this makes sense then the test should be tagged as slowThere 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.
The
CURLOPT_READFUNCTIONcallback is not called after returningCURL_READFUNC_PAUSEuntilcurl_pause(CURLPAUSE_CONT)is called. So I don't think that it will really improve the test.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.
OK then!