-
-
Notifications
You must be signed in to change notification settings - Fork 5.4k
curl return fail if HTTP errors #4448
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
278f38e to
7154c9e
Compare
| #from wget 1.14: do not skip body on 404 error | ||
| if _contains "$(wget --help 2>&1)" "--content-on-error"; then | ||
| _ACME_WGET="$_ACME_WGET --content-on-error " | ||
| fi |
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.
Move these codes from outer into the wget initialization blocks.
So it doesn't need to duplicate evaluate $_ACME_WGET, and the --help does not need the other arguments.
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.
这个改动其实没有必要. 如果 已经初始化过了,__HTTP_INITIALIZED=1, 根本就不会再次走进来.
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.
这个改动确实没有必要性,只是为了改善可读性,使代码结构更清晰一些。用伪代码表示一下改动前的代码是:
if 使用curl
初始化curl
if curl 支持某个特性
初始化特性
fi
fi
if 使用wget
初始化wget
fi
if 使用wget 且 支持某个特性
初始化特性
fi
这个代码结构看着很混乱,curl的所有初始化被放在了if 使用curl这个if块里,但是wget的分成了两块。
所以我希望把它改到if 使用wget里面去,改善可读性。
|
这么改的好处是啥 |
|
@Neilpang 这意味着在使用curl的时候,我们不能直接通过 所以建议给 |
|
@Neilpang |
| fi | ||
|
|
||
| if _contains "$(curl --help 2>&1)" "--globoff"; then | ||
| if _contains "$(curl --help 2>&1)" "--globoff" || _contains "$(curl --help curl 2>&1)" "--globoff"; then |
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.
@Neilpang 你看这样行了吗,先按旧版的help判断,如果找不到再按新版判断
| fi | ||
|
|
||
| #from curl 7.76: return fail on HTTP errors but keep the body | ||
| if _contains "$(curl --help http 2>&1)" "--fail-with-body"; then |
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.
这里是不是也需要改成 2次判断.
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 是从7.73出现的--help <category>这个特性,而curl 7.76才出现的--fail-with-body参数。
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.
https://curl.se/docs/manpage.html#--fail-with-body
For now,
curl --silent https://httpstat.us/404return 0wget -q --content-on-error -O - https://httpstat.us/404return 8To append
--fail-with-bodyargument tocurlto make their behaviors becoming same.