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;
|
||||
} mm[] = {
|
||||
{ .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 }
|
||||
};
|
||||
const char *ext = strrchr (name, '.');
|
||||
@ -325,6 +332,18 @@ load_terms (const char *path,
|
||||
lang);
|
||||
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;
|
||||
for (unsigned int i = 0; NULL != mm[i].ext; i++)
|
||||
if (0 == strcasecmp (mm[i].ext,
|
||||
@ -476,15 +495,26 @@ TEH_load_terms (const struct GNUNET_CONFIGURATION_Handle *cfg)
|
||||
char *path;
|
||||
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 !=
|
||||
GNUNET_CONFIGURATION_get_value_filename (cfg,
|
||||
"exchange",
|
||||
"terms",
|
||||
"TERMS_DIR",
|
||||
&path))
|
||||
{
|
||||
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_WARNING,
|
||||
"exchange",
|
||||
"TERMS");
|
||||
"TERMS_DIR");
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -46,4 +46,13 @@ TEH_handler_terms (struct TEH_RequestHandler *rh,
|
||||
const char *upload_data,
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user