mirror of
https://gitlab.xiph.org/xiph/icecast-server.git
synced 2025-02-02 15:07:36 -05:00
Use 64 bit content-length for fileserving (if supported by system)
svn path=/icecast/trunk/icecast/; revision=8196
This commit is contained in:
parent
da1f023430
commit
5850a9b3c3
12
src/compat.h
12
src/compat.h
@ -10,6 +10,9 @@
|
||||
* and others (see AUTHORS for details).
|
||||
*/
|
||||
|
||||
#ifndef __COMPAT_H__
|
||||
#define __COMPAT_H__
|
||||
|
||||
/* compat.h
|
||||
*
|
||||
* This file contains most of the ugliness for header portability
|
||||
@ -29,3 +32,12 @@
|
||||
# include <inttypes.h>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
#define FORMAT_INT64 "%I64d"
|
||||
#else
|
||||
#define FORMAT_INT64 "%lld"
|
||||
#endif
|
||||
|
||||
#endif /* __COMPAT_H__ */
|
||||
|
||||
|
@ -47,6 +47,7 @@
|
||||
#include "logging.h"
|
||||
#include "cfgfile.h"
|
||||
#include "util.h"
|
||||
#include "compat.h"
|
||||
|
||||
#include "fserve.h"
|
||||
|
||||
@ -379,7 +380,7 @@ int fserve_client_create(client_t *httpclient, char *path)
|
||||
client->content_length = 0;
|
||||
client->buf = malloc(BUFSIZE);
|
||||
if (stat(path, &file_buf) == 0) {
|
||||
client->content_length = file_buf.st_size;
|
||||
client->content_length = (int64_t)file_buf.st_size;
|
||||
}
|
||||
|
||||
global_lock();
|
||||
@ -400,7 +401,7 @@ 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-Length: " FORMAT_INT64 "\r\n"
|
||||
"Content-Type: %s\r\n\r\n",
|
||||
client->content_length,
|
||||
fserve_content_type(path));
|
||||
|
@ -14,6 +14,7 @@
|
||||
#define __FSERVE_H__
|
||||
|
||||
#include <stdio.h>
|
||||
#include "compat.h"
|
||||
|
||||
typedef struct _fserve_t
|
||||
{
|
||||
@ -21,7 +22,7 @@ typedef struct _fserve_t
|
||||
|
||||
FILE *file;
|
||||
int offset;
|
||||
off_t content_length;
|
||||
int64_t content_length;
|
||||
int datasize;
|
||||
int ready;
|
||||
unsigned char *buf;
|
||||
|
Loading…
Reference in New Issue
Block a user