-
-
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1852,9 +1852,14 @@ _inithttp() { | |
| _ACME_CURL="$_ACME_CURL --cacert $CA_BUNDLE " | ||
| fi | ||
|
|
||
| if _contains "$(curl --help 2>&1)" "--globoff"; then | ||
| if _contains "$(curl --help 2>&1)" "--globoff" || _contains "$(curl --help curl 2>&1)" "--globoff"; then | ||
| _ACME_CURL="$_ACME_CURL -g " | ||
| 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 | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 这里是不是也需要改成 2次判断.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 这里完全是一个新特性,所以没有向后兼容的需求。
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| _ACME_CURL="$_ACME_CURL --fail-with-body " | ||
| fi | ||
| fi | ||
|
|
||
| if [ -z "$_ACME_WGET" ] && _exists "wget"; then | ||
|
|
@@ -1872,11 +1877,11 @@ _inithttp() { | |
| elif [ "$CA_BUNDLE" ]; then | ||
| _ACME_WGET="$_ACME_WGET --ca-certificate=$CA_BUNDLE " | ||
| fi | ||
| fi | ||
|
|
||
| #from wget 1.14: do not skip body on 404 error | ||
| if [ "$_ACME_WGET" ] && _contains "$($_ACME_WGET --help 2>&1)" "--content-on-error"; then | ||
| _ACME_WGET="$_ACME_WGET --content-on-error " | ||
| #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 | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Move these codes from outer into the wget initialization blocks.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 这个改动其实没有必要. 如果 已经初始化过了,
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 这个改动确实没有必要性,只是为了改善可读性,使代码结构更清晰一些。用伪代码表示一下改动前的代码是: 这个代码结构看着很混乱,curl的所有初始化被放在了 |
||
| fi | ||
|
|
||
| __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.
@Neilpang 你看这样行了吗,先按旧版的help判断,如果找不到再按新版判断