curl output no longer needs to be saved to tempfile

This commit is contained in:
Zhong Lufan 2023-01-29 15:31:18 +08:00
parent c2126d26ce
commit 8c206a4b73
No known key found for this signature in database
GPG Key ID: BE2B3A1E76AD7D04
2 changed files with 4 additions and 4 deletions

View File

@ -59,9 +59,9 @@ aliapi_rpc() {
_signature=$(_aliapi_signature_rpc "$_http_method" "${_query_str:0:-1}") _signature=$(_aliapi_signature_rpc "$_http_method" "${_query_str:0:-1}")
_query_str+="Signature=$(_aliapi_urlencode "$_signature")" _query_str+="Signature=$(_aliapi_urlencode "$_signature")"
local _curl_out _http_url="https://$_http_host/?$_query_str" local _curl_out _http_url="https://$_http_host/?$_query_str"
_curl_out=$(mktemp) _curl_out=$(curl --location --silent --show-error --request "$_http_method" --write-out "%{http_code}" --connect-timeout 3 "$_http_url")
ALIYUN_SDK_LAST_HTTP_CODE=$(curl --location --silent --show-error --request "$_http_method" --output "$_curl_out" --write-out "%{http_code}" --connect-timeout 3 "$_http_url") && cat "$_curl_out" - <<< "" printf "%s" "${_curl_out:0:-3}"
rm -f "$_curl_out" ALIYUN_SDK_LAST_HTTP_CODE=${_curl_out:${#_curl_out}-3}
[[ $ALIYUN_SDK_LAST_HTTP_CODE -eq 200 ]] && return 0 || return 1 [[ $ALIYUN_SDK_LAST_HTTP_CODE -eq 200 ]] && return 0 || return 1
} }

View File

@ -8,7 +8,7 @@
## 依赖 ## 依赖
* coreutils (`cat`, `date`, `mktemp`, `rm`) * coreutils (`date`)
* curl * curl
* openssl * openssl