aboutsummaryrefslogtreecommitdiff
path: root/src/backend/taler-merchant-httpd_mhd.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2020-08-03 16:42:04 +0200
committerChristian Grothoff <christian@grothoff.org>2020-08-03 16:42:04 +0200
commitab07b05c353f7efa877804092f3529ffe7fb5665 (patch)
treef4f0c8afb8c225f913c53367338f700d0f72da85 /src/backend/taler-merchant-httpd_mhd.c
parent708abb48f8f002e11d399431c959c81842eaf962 (diff)
downloadmerchant-ab07b05c353f7efa877804092f3529ffe7fb5665.tar.gz
merchant-ab07b05c353f7efa877804092f3529ffe7fb5665.tar.bz2
merchant-ab07b05c353f7efa877804092f3529ffe7fb5665.zip
work on GET /tips/ HTML page
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 */