mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-04 13:29:59 -05:00
parent
ebf2116810
commit
f8aceafb13
1 changed files with 44 additions and 3 deletions
|
|
@ -80,6 +80,11 @@ enum state {
|
||||||
STATE_DATA
|
STATE_DATA
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum method {
|
||||||
|
METHOD_GET,
|
||||||
|
METHOD_HEAD
|
||||||
|
};
|
||||||
|
|
||||||
struct connection {
|
struct connection {
|
||||||
pa_http_protocol *protocol;
|
pa_http_protocol *protocol;
|
||||||
pa_iochannel *io;
|
pa_iochannel *io;
|
||||||
|
|
@ -89,6 +94,7 @@ struct connection {
|
||||||
pa_client *client;
|
pa_client *client;
|
||||||
enum state state;
|
enum state state;
|
||||||
char *url;
|
char *url;
|
||||||
|
enum method method;
|
||||||
pa_module *module;
|
pa_module *module;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -327,6 +333,11 @@ static void html_response(
|
||||||
|
|
||||||
http_response(c, code, msg, MIME_HTML);
|
http_response(c, code, msg, MIME_HTML);
|
||||||
|
|
||||||
|
if (c->method == METHOD_HEAD) {
|
||||||
|
pa_ioline_defer_close(c->line);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!text)
|
if (!text)
|
||||||
text = msg;
|
text = msg;
|
||||||
|
|
||||||
|
|
@ -363,6 +374,11 @@ static void handle_root(struct connection *c) {
|
||||||
|
|
||||||
http_response(c, 200, "OK", MIME_HTML);
|
http_response(c, 200, "OK", MIME_HTML);
|
||||||
|
|
||||||
|
if (c->method == METHOD_HEAD) {
|
||||||
|
pa_ioline_defer_close(c->line);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
pa_ioline_puts(c->line,
|
pa_ioline_puts(c->line,
|
||||||
HTML_HEADER(PACKAGE_NAME" "PACKAGE_VERSION)
|
HTML_HEADER(PACKAGE_NAME" "PACKAGE_VERSION)
|
||||||
"<h1>"PACKAGE_NAME" "PACKAGE_VERSION"</h1>\n"
|
"<h1>"PACKAGE_NAME" "PACKAGE_VERSION"</h1>\n"
|
||||||
|
|
@ -402,6 +418,11 @@ static void handle_css(struct connection *c) {
|
||||||
|
|
||||||
http_response(c, 200, "OK", MIME_CSS);
|
http_response(c, 200, "OK", MIME_CSS);
|
||||||
|
|
||||||
|
if (c->method == METHOD_HEAD) {
|
||||||
|
pa_ioline_defer_close(c->line);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
pa_ioline_puts(c->line,
|
pa_ioline_puts(c->line,
|
||||||
"body { color: black; background-color: white; }\n"
|
"body { color: black; background-color: white; }\n"
|
||||||
"a:link, a:visited { color: #900000; }\n"
|
"a:link, a:visited { color: #900000; }\n"
|
||||||
|
|
@ -420,6 +441,12 @@ static void handle_status(struct connection *c) {
|
||||||
pa_assert(c);
|
pa_assert(c);
|
||||||
|
|
||||||
http_response(c, 200, "OK", MIME_TEXT);
|
http_response(c, 200, "OK", MIME_TEXT);
|
||||||
|
|
||||||
|
if (c->method == METHOD_HEAD) {
|
||||||
|
pa_ioline_defer_close(c->line);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
r = pa_full_status_string(c->protocol->core);
|
r = pa_full_status_string(c->protocol->core);
|
||||||
pa_ioline_puts(c->line, r);
|
pa_ioline_puts(c->line, r);
|
||||||
pa_xfree(r);
|
pa_xfree(r);
|
||||||
|
|
@ -439,6 +466,11 @@ static void handle_listen(struct connection *c) {
|
||||||
"<h2>Sinks</h2>\n"
|
"<h2>Sinks</h2>\n"
|
||||||
"<p>\n");
|
"<p>\n");
|
||||||
|
|
||||||
|
if (c->method == METHOD_HEAD) {
|
||||||
|
pa_ioline_defer_close(c->line);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
PA_IDXSET_FOREACH(sink, c->protocol->core->sinks, idx) {
|
PA_IDXSET_FOREACH(sink, c->protocol->core->sinks, idx) {
|
||||||
char *t, *m;
|
char *t, *m;
|
||||||
|
|
||||||
|
|
@ -566,6 +598,10 @@ static void handle_listen_prefix(struct connection *c, const char *source_name)
|
||||||
http_response(c, 200, "OK", t);
|
http_response(c, 200, "OK", t);
|
||||||
pa_xfree(t);
|
pa_xfree(t);
|
||||||
|
|
||||||
|
if(c->method == METHOD_HEAD) {
|
||||||
|
connection_unlink(c);
|
||||||
|
return;
|
||||||
|
}
|
||||||
pa_ioline_set_callback(c->line, NULL, NULL);
|
pa_ioline_set_callback(c->line, NULL, NULL);
|
||||||
|
|
||||||
if (pa_ioline_is_drained(c->line))
|
if (pa_ioline_is_drained(c->line))
|
||||||
|
|
@ -606,10 +642,15 @@ static void line_callback(pa_ioline *line, const char *s, void *userdata) {
|
||||||
|
|
||||||
switch (c->state) {
|
switch (c->state) {
|
||||||
case STATE_REQUEST_LINE: {
|
case STATE_REQUEST_LINE: {
|
||||||
if (!pa_startswith(s, "GET "))
|
if (pa_startswith(s, "GET ")) {
|
||||||
|
c->method = METHOD_GET;
|
||||||
|
s +=4;
|
||||||
|
} else if (pa_startswith(s, "HEAD ")) {
|
||||||
|
c->method = METHOD_HEAD;
|
||||||
|
s +=5;
|
||||||
|
} else {
|
||||||
goto fail;
|
goto fail;
|
||||||
|
}
|
||||||
s +=4;
|
|
||||||
|
|
||||||
c->url = pa_xstrndup(s, strcspn(s, " \r\n\t?"));
|
c->url = pa_xstrndup(s, strcspn(s, " \r\n\t?"));
|
||||||
c->state = STATE_MIME_HEADER;
|
c->state = STATE_MIME_HEADER;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue