mirror of
https://github.com/clearlinux/ok.sh.git
synced 2026-09-06 13:41:47 +00:00
Don't try to guess whether to use GET or POST
Testing this via [ -t ] does not fully work since subshells inherit the file descriptor target. There may still be a way to detect this (perhaps by reading a byte from stdin to see if it's empty or not). I'll revisit this later if I still care. :-) Thanks to lhunath in #bash for the help.
This commit is contained in:
+2
-7
@@ -284,25 +284,20 @@ request() {
|
||||
#
|
||||
# Keyword arguments
|
||||
#
|
||||
# method : GET or POST
|
||||
local method='GET'
|
||||
# The method to use for the HTTP request.
|
||||
# If data is passed to this function via stdin, 'POST' will be used as
|
||||
# the default instead of 'GET'.
|
||||
local content_type='application/json'
|
||||
# The value of the Content-Type header to use for the request.
|
||||
|
||||
shift 1
|
||||
|
||||
local method cmd arg has_stdin trace_curl
|
||||
local cmd arg has_stdin trace_curl
|
||||
|
||||
case $path in
|
||||
(http*) : ;;
|
||||
*) path="${OCTOKIT_SH_URL}${path}" ;;
|
||||
esac
|
||||
|
||||
method='GET'
|
||||
[ ! -t 0 ] && method='POST'
|
||||
|
||||
for arg in "$@"; do
|
||||
case $arg in
|
||||
(method=*) method="${arg#*=}";;
|
||||
|
||||
Reference in New Issue
Block a user