1
0
mirror of https://gitlab.xiph.org/xiph/icecast-server.git synced 2024-11-03 04:17:17 -05:00

add Content-Length to files served via the fserve to enable seeking

svn path=/icecast/trunk/icecast/; revision=8192
This commit is contained in:
oddsock 2004-11-11 16:21:01 +00:00
parent 80078cce1d
commit 4e20c79edf
2 changed files with 9 additions and 0 deletions

View File

@ -18,6 +18,7 @@
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#ifdef HAVE_POLL
#include <sys/poll.h>
@ -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;

View File

@ -21,6 +21,7 @@ typedef struct _fserve_t
FILE *file;
int offset;
off_t content_length;
int datasize;
int ready;
unsigned char *buf;