fix: accept POST form posts on every Subsonic endpoint
Clients that use the formPost extension (Feishin, Symfonium) send requests as application/x-www-form-urlencoded POSTs, not only GET. Register both methods for every route and cover it in the smoke test.
This commit is contained in:
1 parent
4d313a2846
commit
1571ec65ff
9 files changed
+168
-113
No files matched your search
@@ -116,6 +116,26 @@ check() {
|
||||
pass "$name"
|
||||
}
|
||||
|
||||
# check_post <name> <path> <extra-form-data>
|
||||
check_post() {
|
||||
local name="$1" path="$2" extra="${3:-}" body status
|
||||
body="$(curl -s -w '\n%{http_code}' -X POST \
|
||||
-H 'Content-Type: application/x-www-form-urlencoded' \
|
||||
--data "${AUTH}${extra}" "$BASE$path")"
|
||||
status="$(printf '%s' "$body" | tail -1)"
|
||||
body="$(printf '%s' "$body" | sed '$d')"
|
||||
|
||||
if [[ "$status" != "200" ]]; then
|
||||
fail "$name (POST)" "HTTP $status: $(printf '%s' "$body" | head -c 200)"
|
||||
return
|
||||
fi
|
||||
if ! printf '%s' "$body" | grep -q '"status":"ok"'; then
|
||||
fail "$name (POST)" "$(printf '%s' "$body" | head -c 200)"
|
||||
return
|
||||
fi
|
||||
pass "$name (POST)"
|
||||
}
|
||||
|
||||
check "ping" "/rest/ping.view?$AUTH"
|
||||
check "getLicense" "/rest/getLicense.view?$AUTH"
|
||||
check "getOpenSubsonicExtensions" "/rest/getOpenSubsonicExtensions.view?$AUTH"
|
||||
@@ -145,6 +165,13 @@ check "getTopSongs" "/rest/getTopSongs.view?$AUTH&artist=Smoke%20Artist"
|
||||
check "getInternetRadioStations" "/rest/getInternetRadioStations.view?$AUTH"
|
||||
check "jukeboxControl" "/rest/jukeboxControl.view?$AUTH&action=status"
|
||||
|
||||
# The formPost extension means clients may use POST for every endpoint.
|
||||
check_post "ping" "/rest/ping.view"
|
||||
check_post "getAlbumList2" "/rest/getAlbumList2.view" "&type=alphabeticalByName&size=10"
|
||||
check_post "getGenres" "/rest/getGenres.view"
|
||||
check_post "getPlaylists" "/rest/getPlaylists.view"
|
||||
check_post "getUser" "/rest/getUser.view" "&username=$USER"
|
||||
|
||||
check "scrobble" "/rest/scrobble.view?$AUTH&id=$SONG_ID"
|
||||
check "star" "/rest/star.view?$AUTH&id=$SONG_ID&albumId=$ALBUM_ID&artistId=$ARTIST_ID"
|
||||
check "getStarred2 after star" "/rest/getStarred2.view?$AUTH"
|
||||
|
||||
Reference in new issue
Block a user