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:
Seth House
2015-04-01 16:54:34 -06:00
parent c2051c506b
commit 2cac303c42
+2 -7
View File
@@ -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#*=}";;