Differentiate between http and https.

This commit is contained in:
Josh W 2020-02-10 11:50:03 -05:00
parent 70fa77dc9d
commit 62d2cd93c4

View file

@ -63,7 +63,11 @@ def next_song() =
log = log(label="next_song")
log("Requesting the next song from #{url_next}")
if string.contains(prefix='https') then
let (status, _, data) = https.get(headers=api_headers_next, url_next)
else
let (status, _, data) = http.get(headers=api_headers_next, url_next)
end
let (_, status_code, _) = status
log(data)
@ -99,7 +103,11 @@ def just_played(m) =
if m["req_id"] != "" then
log('Letting server know we played request ID #{m["req_id"]} here: #{url_played}')
played_song = json_of(compact=true, [("song_request", int_of_string(m["req_id"]))])
if string.contains(prefix='https') then
let (status, _, data) = https.post(headers=api_headers_played, data=played_song, url_played)
else
let (status, _, data) = http.post(headers=api_headers_played, data=played_song, url_played)
end
let (_, status_code, _) = status
if status_code == 204 then