|
|
@ -79,8 +79,8 @@ static int enablestatic;
|
|
|
|
|
|
|
|
|
|
|
|
/*! \brief Limit the kinds of files we're willing to serve up */
|
|
|
|
/*! \brief Limit the kinds of files we're willing to serve up */
|
|
|
|
static struct {
|
|
|
|
static struct {
|
|
|
|
char *ext;
|
|
|
|
const char *ext;
|
|
|
|
char *mtype;
|
|
|
|
const char *mtype;
|
|
|
|
} mimetypes[] = {
|
|
|
|
} mimetypes[] = {
|
|
|
|
{ "png", "image/png" },
|
|
|
|
{ "png", "image/png" },
|
|
|
|
{ "jpg", "image/jpeg" },
|
|
|
|
{ "jpg", "image/jpeg" },
|
|
|
@ -88,10 +88,11 @@ static struct {
|
|
|
|
{ "wav", "audio/x-wav" },
|
|
|
|
{ "wav", "audio/x-wav" },
|
|
|
|
{ "mp3", "audio/mpeg" },
|
|
|
|
{ "mp3", "audio/mpeg" },
|
|
|
|
{ "svg", "image/svg+xml" },
|
|
|
|
{ "svg", "image/svg+xml" },
|
|
|
|
|
|
|
|
{ "svgz", "image/svg+xml" },
|
|
|
|
{ "gif", "image/gif" },
|
|
|
|
{ "gif", "image/gif" },
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
static char *ftype2mtype(const char *ftype, char *wkspace, int wkspacelen)
|
|
|
|
static const char *ftype2mtype(const char *ftype, char *wkspace, int wkspacelen)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
int x;
|
|
|
|
int x;
|
|
|
|
if (ftype) {
|
|
|
|
if (ftype) {
|
|
|
@ -109,7 +110,8 @@ static char *static_callback(struct sockaddr_in *req, const char *uri, struct as
|
|
|
|
char result[4096];
|
|
|
|
char result[4096];
|
|
|
|
char *c=result;
|
|
|
|
char *c=result;
|
|
|
|
char *path;
|
|
|
|
char *path;
|
|
|
|
char *ftype, *mtype;
|
|
|
|
char *ftype;
|
|
|
|
|
|
|
|
const char *mtype;
|
|
|
|
char wkspace[80];
|
|
|
|
char wkspace[80];
|
|
|
|
struct stat st;
|
|
|
|
struct stat st;
|
|
|
|
int len;
|
|
|
|
int len;
|
|
|
@ -128,7 +130,7 @@ static char *static_callback(struct sockaddr_in *req, const char *uri, struct as
|
|
|
|
|
|
|
|
|
|
|
|
if ((ftype = strrchr(uri, '.')))
|
|
|
|
if ((ftype = strrchr(uri, '.')))
|
|
|
|
ftype++;
|
|
|
|
ftype++;
|
|
|
|
mtype=ftype2mtype(ftype, wkspace, sizeof(wkspace));
|
|
|
|
mtype = ftype2mtype(ftype, wkspace, sizeof(wkspace));
|
|
|
|
|
|
|
|
|
|
|
|
/* Cap maximum length */
|
|
|
|
/* Cap maximum length */
|
|
|
|
len = strlen(uri) + strlen(ast_config_AST_DATA_DIR) + strlen("/static-http/") + 5;
|
|
|
|
len = strlen(uri) + strlen(ast_config_AST_DATA_DIR) + strlen("/static-http/") + 5;
|
|
|
|