diff paster.sh @ 61:a93f4e3313e9

misc: add a raw option in POST data The previous paster.sh implementation was grep'ing the Location header which could fail if followlocation is enabled because multiple location can be returned by the HTTP server. And obviously while here, add the followlocation option.
author David Demelier <markand@malikania.fr>
date Thu, 26 May 2022 10:44:10 +0200
parents ecb0b90d94d8
children 1a98bc0daa49
line wrap: on
line diff
--- a/paster.sh	Sun Jan 02 10:24:20 2022 +0100
+++ b/paster.sh	Thu May 26 10:44:10 2022 +0200
@@ -238,13 +238,16 @@
 
 	if [ $verbose -eq 0 ]; then
 		with_verbose="-s"
+	else
+		with_verbose="-i"
 	fi
 
-	curl -i -X POST \
+	curl -L -X POST \
 		--data author="$author" \
 		--data language="$language" \
 		--data duration="$duration" \
 		--data title="$title" \
+		--data raw="on" \
 		--data-urlencode code@"$1" \
 		$with_private \
 		$with_verbose \
@@ -293,15 +296,4 @@
 	usage
 fi
 
-# If verbose, dump all headers.
-if [ $verbose -eq 1 ]; then
-	send "$1" "$2"
-else
-	url=$(send "$1" "$2" | grep -E "^Location: " | awk '{ print $2 }')
-
-	if [ -z "$url" ]; then
-		die "abort: error occured, retry with -v"
-	fi
-
-	printf "%s%s\n" "$2" "$url"
-fi
+send "$1" "$2"