summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2019-12-02 21:41:24 +0100
committerChristian Grothoff <christian@grothoff.org>2019-12-02 21:41:24 +0100
commit6c5d46327bc09b1de2c5f1fb41290b7da4aed8d0 (patch)
tree2c33fc970a11e09dd3d53df9af60a5591c304543
parent1043bc839f6bbdf23eb0aa0c4a84165b91828753 (diff)
downloadexchange-6c5d46327bc09b1de2c5f1fb41290b7da4aed8d0.tar.gz
exchange-6c5d46327bc09b1de2c5f1fb41290b7da4aed8d0.tar.bz2
exchange-6c5d46327bc09b1de2c5f1fb41290b7da4aed8d0.zip
add more mime types, handle etag nicelydemo-2019-12-03-01
-rw-r--r--src/exchange/taler-exchange-httpd_terms.c34
-rw-r--r--src/exchange/taler-exchange-httpd_terms.h9
2 files changed, 41 insertions, 2 deletions
diff --git a/src/exchange/taler-exchange-httpd_terms.c b/src/exchange/taler-exchange-httpd_terms.c
index dadc1588..8c25e538 100644
--- a/src/exchange/taler-exchange-httpd_terms.c
+++ b/src/exchange/taler-exchange-httpd_terms.c
@@ -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,
@@ -477,14 +496,25 @@ TEH_load_terms (const struct GNUNET_CONFIGURATION_Handle *cfg)
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;
}
diff --git a/src/exchange/taler-exchange-httpd_terms.h b/src/exchange/taler-exchange-httpd_terms.h
index 1cfd8239..18a42809 100644
--- a/src/exchange/taler-exchange-httpd_terms.h
+++ b/src/exchange/taler-exchange-httpd_terms.h
@@ -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