Skip to content

Commit

Permalink
Merge pull request #21 from vikpe/master
Browse files Browse the repository at this point in the history
Add demo_filenames.txt endpoint to http server.
  • Loading branch information
tcsabina authored Oct 30, 2022
2 parents f4150f7 + 124efe4 commit 8f4926c
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/httpsv.c
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,10 @@ void HTTPSV_GetMethod(cluster_t *cluster, oproxy_t *pend)
{
HTTPSV_GenerateDemoListing(cluster, pend);
}
else if (URLCOMPARE(getpath, "/demo_filenames", skiplen))
{
HTTPSV_GenerateDemoFilenames(cluster, pend);
}
else if (!strcmp(getpath, "/style.css"))
{
HTTPSV_GenerateCSSFile(cluster, pend);
Expand Down
22 changes: 22 additions & 0 deletions src/httpsv_generate.c
Original file line number Diff line number Diff line change
Expand Up @@ -704,6 +704,28 @@ void HTTPSV_GenerateDemoListing(cluster_t *cluster, oproxy_t *dest)
HTTPSV_SendHTMLFooter(cluster, dest);
}

void HTTPSV_GenerateDemoFilenames(cluster_t *cluster, oproxy_t *dest)
{
char row_buf[1024];
int i;

if (dest != NULL) {
dest->_bufferautoadjustmaxsize_ = 1024 * 1024; // NOTE: this allow 1MB buffer...
}

HTTPSV_SendHTTPHeader(cluster, dest, "200", "text/plain", true);

Cluster_BuildAvailableDemoList(cluster);

if (cluster != NULL) {
for (i = 0; i < cluster->availdemoscount; i++)
{
snprintf(row_buf, sizeof(row_buf), "%s%s", cluster->availdemos[i].name, CRLF);
Net_ProxySend(cluster, dest, row_buf, strlen(row_buf));
}
}
}

void HTTPSV_GenerateImage(cluster_t *cluster, oproxy_t *dest, char *imgfilename)
{
int s;
Expand Down
1 change: 1 addition & 0 deletions src/qtv.h
Original file line number Diff line number Diff line change
Expand Up @@ -1069,6 +1069,7 @@ void HTTPSV_GenerateQTVStub(cluster_t *cluster, oproxy_t *dest, char *streamty
void HTTPSV_GenerateQTVJoinStub(cluster_t *cluster, oproxy_t *dest, char *streamid);
void HTTPSV_GenerateAdmin(cluster_t *cluster, oproxy_t *dest, int streamid, char *postbody);
void HTTPSV_GenerateDemoListing(cluster_t *cluster, oproxy_t *dest);
void HTTPSV_GenerateDemoFilenames(cluster_t *cluster, oproxy_t *dest);
void HTTPSV_GenerateImage(cluster_t *cluster, oproxy_t *dest, char *imgfilename);
void HTTPSV_GenerateLevelshot(cluster_t *cluster, oproxy_t *dest, char *name);
void HTTPSV_GenerateDemoDownload(cluster_t *cluster, oproxy_t *dest, char *name);
Expand Down

0 comments on commit 8f4926c

Please sign in to comment.