aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2016-11-29 22:19:50 +0100
committerMichael Niedermayer <michael@niedermayer.cc>2016-11-30 11:25:17 +0100
commit8cbdaa4b01ef2fc723c30c175cb4c2ec84b235bf (patch)
tree72ab581c9e53db2969920ad93691d20896d6551f
parent2c908f22c2af0775a6ffe3466aad174a0ace00dd (diff)
downloadffmpeg-8cbdaa4b01ef2fc723c30c175cb4c2ec84b235bf.tar.gz
ffserver: Add client requested urls to the status page
Fixes Ticket3791 Reviewed-by: "Reynaldo H. Verdejo Pinochet" <reynaldo@osg.samsung.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
-rw-r--r--ffserver.c38
-rwxr-xr-xtests/ffserver-regression.sh2
-rw-r--r--tests/ffserver.regression.ref2
3 files changed, 37 insertions, 5 deletions
diff --git a/ffserver.c b/ffserver.c
index 20f5995d25..8745181379 100644
--- a/ffserver.c
+++ b/ffserver.c
@@ -164,6 +164,7 @@ typedef struct HTTPContext {
char protocol[16];
char method[16];
char url[128];
+ char clean_url[128*7];
int buffer_size;
uint8_t *buffer;
int is_packetized; /* if true, the stream is packetized */
@@ -1920,6 +1921,34 @@ static inline void print_stream_params(AVIOContext *pb, FFServerStream *stream)
avio_printf(pb, "</table>\n");
}
+static void clean_html(char *clean, int clean_len, char *dirty)
+{
+ int i, o;
+
+ for (o = i = 0; o+10 < clean_len && dirty[i];) {
+ int len = strspn(dirty+i, "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$-_.+!*(),?/ :;%");
+ if (len) {
+ if (o + len >= clean_len)
+ break;
+ memcpy(clean + o, dirty + i, len);
+ i += len;
+ o += len;
+ } else {
+ int c = dirty[i++];
+ switch (c) {
+ case '&': av_strlcat(clean+o, "&amp;" , clean_len - o); break;
+ case '<': av_strlcat(clean+o, "&lt;" , clean_len - o); break;
+ case '>': av_strlcat(clean+o, "&gt;" , clean_len - o); break;
+ case '\'': av_strlcat(clean+o, "&apos;" , clean_len - o); break;
+ case '\"': av_strlcat(clean+o, "&quot;" , clean_len - o); break;
+ default: av_strlcat(clean+o, "&#9785;", clean_len - o); break;
+ }
+ o += strlen(clean+o);
+ }
+ }
+ clean[o] = 0;
+}
+
static void compute_status(HTTPContext *c)
{
HTTPContext *c1;
@@ -2107,7 +2136,7 @@ static void compute_status(HTTPContext *c)
current_bandwidth, config.max_bandwidth);
avio_printf(pb, "<table>\n");
- avio_printf(pb, "<tr><th>#<th>File<th>IP<th>Proto<th>State<th>Target "
+ avio_printf(pb, "<tr><th>#<th>File<th>IP<th>URL<th>Proto<th>State<th>Target "
"bit/s<th>Actual bit/s<th>Bytes transferred\n");
c1 = first_http_ctx;
i = 0;
@@ -2127,10 +2156,13 @@ static void compute_status(HTTPContext *c)
i++;
p = inet_ntoa(c1->from_addr.sin_addr);
- avio_printf(pb, "<tr><td><b>%d</b><td>%s%s<td>%s<td>%s<td>%s"
+ clean_html(c1->clean_url, sizeof(c1->clean_url), c1->url);
+ avio_printf(pb, "<tr><td><b>%d</b><td>%s%s<td>%s<td>%s<td>%s<td>%s"
"<td align=right>",
i, c1->stream ? c1->stream->filename : "",
- c1->state == HTTPSTATE_RECEIVE_DATA ? "(input)" : "", p,
+ c1->state == HTTPSTATE_RECEIVE_DATA ? "(input)" : "",
+ p,
+ c1->clean_url,
c1->protocol, http_state[c1->state]);
fmt_bytecount(pb, bitrate);
avio_printf(pb, "<td align=right>");
diff --git a/tests/ffserver-regression.sh b/tests/ffserver-regression.sh
index b776bad740..17e906086a 100755
--- a/tests/ffserver-regression.sh
+++ b/tests/ffserver-regression.sh
@@ -28,7 +28,7 @@ sleep 2
fi
do_md5sum ff-$file >>ffserver.regression
done
- wget $WGET_OPTIONS -O - teststat.html http://localhost:9999/teststat.html > ff-stat 2>/dev/null
+ wget $WGET_OPTIONS -O - 'http://localhost:9999/teststat.html?abc' > ff-stat 2>/dev/null
do_md5sum ff-stat >>ffserver.regression
)
kill $FFSERVER_PID
diff --git a/tests/ffserver.regression.ref b/tests/ffserver.regression.ref
index ec7b37c6de..8629d528da 100644
--- a/tests/ffserver.regression.ref
+++ b/tests/ffserver.regression.ref
@@ -8,4 +8,4 @@ d41d8cd98f00b204e9800998ecf8427e *ff-test_l.rm
4c887dfc1dd0f6ea1a3a2be6dd32e495 *ff-test.jpg
1d04b73b04aad27793cc762d5afabac1 *ff-test_small.jpg
bc36c40ee34ebee6ffe50f3094aab733 *ff-test.mjpg
-9b72c3d6d89a038fa141fe636baa2c0e *ff-stat
+56c8b3ba2c4f3eebfa6d2a895e042ee3 *ff-stat