From 4e20c79edf0ec78b6ea0fc98919e73fc02f497d8 Mon Sep 17 00:00:00 2001 From: oddsock Date: Thu, 11 Nov 2004 16:21:01 +0000 Subject: [PATCH] add Content-Length to files served via the fserve to enable seeking svn path=/icecast/trunk/icecast/; revision=8192 --- src/fserve.c | 8 ++++++++ src/fserve.h | 1 + 2 files changed, 9 insertions(+) diff --git a/src/fserve.c b/src/fserve.c index 50ead08e..cdc088f6 100644 --- a/src/fserve.c +++ b/src/fserve.c @@ -18,6 +18,7 @@ #include #include #include +#include #ifdef HAVE_POLL #include @@ -360,6 +361,7 @@ int fserve_client_create(client_t *httpclient, char *path) int bytes; int client_limit; ice_config_t *config = config_get_config(); + struct stat file_buf; client_limit = config->client_limit; config_release_config(); @@ -374,7 +376,11 @@ int fserve_client_create(client_t *httpclient, char *path) client->offset = 0; client->datasize = 0; client->ready = 0; + client->content_length = 0; client->buf = malloc(BUFSIZE); + if (stat(path, &file_buf) == 0) { + client->content_length = file_buf.st_size; + } global_lock(); if(global.clients >= client_limit) { @@ -394,7 +400,9 @@ int fserve_client_create(client_t *httpclient, char *path) httpclient->respcode = 200; bytes = sock_write(httpclient->con->sock, "HTTP/1.0 200 OK\r\n" + "Content-Length: %ld\r\n" "Content-Type: %s\r\n\r\n", + client->content_length, fserve_content_type(path)); if(bytes > 0) httpclient->con->sent_bytes = bytes; diff --git a/src/fserve.h b/src/fserve.h index d35fdfaa..327d5f6f 100644 --- a/src/fserve.h +++ b/src/fserve.h @@ -21,6 +21,7 @@ typedef struct _fserve_t FILE *file; int offset; + off_t content_length; int datasize; int ready; unsigned char *buf;