-
Notifications
You must be signed in to change notification settings - Fork 56
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
Support CURLOPT_RESOLVE option for SWOOLE_HOOK_CURL #107
Conversation
src/core/Curl/Handler.php
Outdated
@@ -412,6 +426,15 @@ private function setOption(int $opt, $value): bool | |||
$this->nobody = boolval($value); | |||
$this->method = 'HEAD'; | |||
break; | |||
case CURLOPT_RESOLVE: | |||
foreach ((array) $value as $resolve) { | |||
$tmpResolve = explode(':', $resolve); |
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.
限制分割次数为3, IPV6地址里有:
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.
curl的格式要求是[+]HOST:PORT:ADDRESS[,ADDRESS]...
这里没有处理前导加号也没有处理多地址
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.
看一些sdk里用到的都是一个[HOST:PORT:ADDRESS]
,PHP这里应该不需要支持多地址吧
PHP curl 多地址: [HOST:PORT:ADDRESS], [HOST:PORT:ADDRESS]
后面的会覆盖前面的,[HOST:PORT:ADDRESS,ADDRESS]
读的前面的
src/core/Curl/Handler.php
Outdated
@@ -412,6 +426,15 @@ private function setOption(int $opt, $value): bool | |||
$this->nobody = boolval($value); | |||
$this->method = 'HEAD'; | |||
break; | |||
case CURLOPT_RESOLVE: | |||
foreach ((array) $value as $resolve) { | |||
$tmpResolve = explode(':', $resolve); |
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.
curl的格式要求是[+]HOST:PORT:ADDRESS[,ADDRESS]...
这里没有处理前导加号也没有处理多地址
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.
Some of following cases not yet covered.
#!/usr/bin/env bash
set -x
curl -i \
--resolve "+httpbin.org:443:127.0.0.1" \
https://httpbin.org/get
curl -i \
--resolve "httpbin.org:443:127.0.0.1" \
--resolve "httpbin.org:443:$(dig +short httpbin.org | head -n 1)" \
https://httpbin.org/get
curl -i \
--resolve "httpbin.org:443:$(dig +short httpbin.org | head -n 1)" \
--resolve "+httpbin.org:443:127.0.0.1" \
https://httpbin.org/get
curl -i \
--resolve "httpbin.org:443:$(dig +short httpbin.org | head -n 1)" \
--resolve "httpbin.org:443:127.0.0.1" \
https://httpbin.org/get
curl -i \
--resolve "httpbin.org:443:$(dig +short httpbin.org | head -n 1)" \
--resolve "httpbin.org:443:127.0.0.1" \
--resolve "-httpbin.org:443:127.0.0.1" \
https://httpbin.org/get
Personally, I feel it should be fine to treat +HOST:...
the same as HOST:...
in the library.
Fix swoole/swoole-src#4219