add more mime types, handle etag nicely
This commit is contained in:
parent
1043bc839f
commit
6c5d46327b
@ -311,6 +311,13 @@ load_terms (const char *path,
|
|||||||
const char *mime;
|
const char *mime;
|
||||||
} mm[] = {
|
} mm[] = {
|
||||||
{ .ext = "html", .mime = "text/html" },
|
{ .ext = "html", .mime = "text/html" },
|
||||||
|
{ .ext = "htm", .mime = "text/html" },
|
||||||
|
{ .ext = "txt", .mime = "text/plain" },
|
||||||
|
{ .ext = "pdf", .mime = "application/pdf" },
|
||||||
|
{ .ext = "jpg", .mime = "image/jpeg" },
|
||||||
|
{ .ext = "jpeg", .mime = "image/jpeg" },
|
||||||
|
{ .ext = "png", .mime = "image/png" },
|
||||||
|
{ .ext = "gif", .mime = "image/gif" },
|
||||||
{ .ext = NULL, .mime = NULL }
|
{ .ext = NULL, .mime = NULL }
|
||||||
};
|
};
|
||||||
const char *ext = strrchr (name, '.');
|
const char *ext = strrchr (name, '.');
|
||||||
@ -325,6 +332,18 @@ load_terms (const char *path,
|
|||||||
lang);
|
lang);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (0 != strncmp (terms_etag,
|
||||||
|
name,
|
||||||
|
ext - name - 1))
|
||||||
|
{
|
||||||
|
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
|
||||||
|
"Filename `%s' does not match Etag `%s' in directory `%s/%s'. Ignoring it.\n",
|
||||||
|
name,
|
||||||
|
terms_etag,
|
||||||
|
path,
|
||||||
|
lang);
|
||||||
|
return;
|
||||||
|
}
|
||||||
mime = NULL;
|
mime = NULL;
|
||||||
for (unsigned int i = 0; NULL != mm[i].ext; i++)
|
for (unsigned int i = 0; NULL != mm[i].ext; i++)
|
||||||
if (0 == strcasecmp (mm[i].ext,
|
if (0 == strcasecmp (mm[i].ext,
|
||||||
@ -476,15 +495,26 @@ TEH_load_terms (const struct GNUNET_CONFIGURATION_Handle *cfg)
|
|||||||
char *path;
|
char *path;
|
||||||
DIR *d;
|
DIR *d;
|
||||||
|
|
||||||
|
if (GNUNET_OK !=
|
||||||
|
GNUNET_CONFIGURATION_get_value_string (cfg,
|
||||||
|
"exchange",
|
||||||
|
"TERMS_ETAG",
|
||||||
|
&terms_etag))
|
||||||
|
{
|
||||||
|
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_WARNING,
|
||||||
|
"exchange",
|
||||||
|
"TERMS_ETAG");
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (GNUNET_OK !=
|
if (GNUNET_OK !=
|
||||||
GNUNET_CONFIGURATION_get_value_filename (cfg,
|
GNUNET_CONFIGURATION_get_value_filename (cfg,
|
||||||
"exchange",
|
"exchange",
|
||||||
"terms",
|
"TERMS_DIR",
|
||||||
&path))
|
&path))
|
||||||
{
|
{
|
||||||
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_WARNING,
|
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_WARNING,
|
||||||
"exchange",
|
"exchange",
|
||||||
"TERMS");
|
"TERMS_DIR");
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -46,4 +46,13 @@ TEH_handler_terms (struct TEH_RequestHandler *rh,
|
|||||||
const char *upload_data,
|
const char *upload_data,
|
||||||
size_t *upload_data_size);
|
size_t *upload_data_size);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load our terms of service as per configuration.
|
||||||
|
*
|
||||||
|
* @param cfg configuration to process
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
TEH_load_terms (const struct GNUNET_CONFIGURATION_Handle *cfg);
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user