Skip to content

Commit f7e5a9b

Browse files
committed
audio service - changed from GET method to POST
1 parent aa0b7e4 commit f7e5a9b

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

audio.cpp

+5-4
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ using namespace std;
44
void AudioResponder::reply(ostream& out, cxxtools::http::Request& request, cxxtools::http::Reply& reply)
55
{
66
QueryHandler::addHeader(reply);
7+
QueryHandler q("/audio", request);
78

89
if (request.method() == "POST") {
9-
QueryHandler q("/audio", request);
1010
string vol = q.getOptionAsString("volume");
1111
int level = q.getOptionAsInt("volume");
1212
int mute = q.getOptionAsInt("mute");
@@ -45,7 +45,9 @@ void AudioResponder::reply(ostream& out, cxxtools::http::Request& request, cxxto
4545
if (channel >= 0 && channel < 3) {
4646
cDevice::PrimaryDevice()->SetAudioChannel(channel);
4747
}
48-
48+
}
49+
50+
if (request.method() == "POST" || request.method() == "GET") {
4951
AudioList* audioList;
5052
if ( q.isFormat(".html") ) {
5153
reply.addHeader("Content-Type", "text/html; charset=utf-8");
@@ -62,9 +64,8 @@ void AudioResponder::reply(ostream& out, cxxtools::http::Request& request, cxxto
6264
audioList->addContent();
6365
audioList->finish();
6466
delete audioList;
65-
6667
} else {
67-
reply.httpReturn(403, "Only POST method is supported by the audio control");
68+
reply.httpReturn(403, "Only GET and POST methods are supported by the audio control");
6869
}
6970
}
7071

audio.o

144 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)