Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add demo_filenames.txt endpoint to http server. #21

Merged
merged 2 commits into from
Oct 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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