aboutsummaryrefslogtreecommitdiff
path: root/src/backend/taler-merchant-httpd_mhd.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/taler-merchant-httpd_mhd.c')
-rw-r--r--src/backend/taler-merchant-httpd_mhd.c49
1 files changed, 49 insertions, 0 deletions
diff --git a/src/backend/taler-merchant-httpd_mhd.c b/src/backend/taler-merchant-httpd_mhd.c
index 698c2ac5..754c53b1 100644
--- a/src/backend/taler-merchant-httpd_mhd.c
+++ b/src/backend/taler-merchant-httpd_mhd.c
@@ -71,4 +71,53 @@ TMH_MHD_handler_agpl_redirect (const struct TMH_RequestHandler *rh,
}
+/**
+ * Test if the client requested HTML output.
+ *
+ * @param connection client to test
+ * @return true if HTML was requested
+ */
+bool
+TMH_MHD_test_html_desired (struct MHD_Connection *connection)
+{
+ bool ret;
+ const char *accept;
+
+ accept = MHD_lookup_connection_value (connection,
+ MHD_HEADER_KIND,
+ MHD_HTTP_HEADER_ACCEPT);
+ if (NULL != accept)
+ {
+ char *a = GNUNET_strdup (accept);
+ char *saveptr;
+
+ for (char *t = strtok_r (a, ",", &saveptr);
+ NULL != t;
+ t = strtok_r (NULL, ",", &saveptr))
+ {
+ char *end;
+
+ /* skip leading whitespace */
+ while (isspace ((unsigned char) t[0]))
+ t++;
+ /* trim of ';q=' parameter and everything after space */
+ end = strchr (t, ';');
+ if (NULL != end)
+ *end = '\0';
+ end = strchr (t, ' ');
+ if (NULL != end)
+ *end = '\0';
+ if (0 == strcasecmp ("text/html",
+ t))
+ {
+ ret = true;
+ break;
+ }
+ }
+ GNUNET_free (a);
+ }
+ return ret;
+}
+
+
/* end of taler-exchange-httpd_mhd.c */