LCOV - code coverage report
Current view: top level - backend - taler-merchant-httpd_mhd.c (source / functions) Hit Total Coverage
Test: GNU Taler merchant coverage report Lines: 0 25 0.0 %
Date: 2022-08-25 06:17:04 Functions: 0 3 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :   This file is part of TALER
       3             :   Copyright (C) 2014-2020 Taler Systems SA
       4             : 
       5             :   TALER is free software; you can redistribute it and/or modify it under the
       6             :   terms of the GNU Affero General Public License as published by the Free Software
       7             :   Foundation; either version 3, or (at your option) any later version.
       8             : 
       9             :   TALER is distributed in the hope that it will be useful, but WITHOUT ANY
      10             :   WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
      11             :   A PARTICULAR PURPOSE.  See the GNU Affero General Public License for more details.
      12             : 
      13             :   You should have received a copy of the GNU Affero General Public License along with
      14             :   TALER; see the file COPYING.  If not, see <http://www.gnu.org/licenses/>
      15             : */
      16             : /**
      17             :  * @file taler-merchant-httpd_mhd.c
      18             :  * @brief helpers for MHD interaction; these are TALER_EXCHANGE_handler_ functions
      19             :  *        that generate simple MHD replies that do not require any real operations
      20             :  *        to be performed (error handling, static pages, etc.)
      21             :  * @author Florian Dold
      22             :  * @author Benedikt Mueller
      23             :  * @author Christian Grothoff
      24             :  */
      25             : #include "platform.h"
      26             : #include <jansson.h>
      27             : #include "taler-merchant-httpd_mhd.h"
      28             : 
      29             : 
      30             : MHD_RESULT
      31           0 : TMH_MHD_handler_static_response (const struct TMH_RequestHandler *rh,
      32             :                                  struct MHD_Connection *connection,
      33             :                                  struct TMH_HandlerContext *hc)
      34             : {
      35             :   (void) hc;
      36           0 :   return TALER_MHD_reply_static (connection,
      37             :                                  rh->response_code,
      38             :                                  rh->mime_type,
      39           0 :                                  rh->data,
      40             :                                  rh->data_size);
      41             : }
      42             : 
      43             : 
      44             : MHD_RESULT
      45           0 : TMH_MHD_handler_agpl_redirect (const struct TMH_RequestHandler *rh,
      46             :                                struct MHD_Connection *connection,
      47             :                                struct TMH_HandlerContext *hc)
      48             : {
      49             :   (void) rh;
      50             :   (void) hc;
      51           0 :   return TALER_MHD_reply_agpl (connection,
      52             :                                "http://www.git.taler.net/?p=merchant.git");
      53             : }
      54             : 
      55             : 
      56             : bool
      57           0 : TMH_MHD_test_html_desired (struct MHD_Connection *connection)
      58             : {
      59           0 :   bool ret = false;
      60             :   const char *accept;
      61             : 
      62           0 :   accept = MHD_lookup_connection_value (connection,
      63             :                                         MHD_HEADER_KIND,
      64             :                                         MHD_HTTP_HEADER_ACCEPT);
      65           0 :   if (NULL != accept)
      66             :   {
      67           0 :     char *a = GNUNET_strdup (accept);
      68             :     char *saveptr;
      69             : 
      70           0 :     for (char *t = strtok_r (a, ",", &saveptr);
      71             :          NULL != t;
      72           0 :          t = strtok_r (NULL, ",", &saveptr))
      73             :     {
      74             :       char *end;
      75             : 
      76             :       /* skip leading whitespace */
      77           0 :       while (isspace ((unsigned char) t[0]))
      78           0 :         t++;
      79             :       /* trim of ';q=' parameter and everything after space */
      80           0 :       end = strchr (t, ';');
      81           0 :       if (NULL != end)
      82           0 :         *end = '\0';
      83           0 :       end = strchr (t, ' ');
      84           0 :       if (NULL != end)
      85           0 :         *end = '\0';
      86           0 :       if (0 == strcasecmp ("text/html",
      87             :                            t))
      88             :       {
      89           0 :         ret = true;
      90           0 :         break;
      91             :       }
      92             :     }
      93           0 :     GNUNET_free (a);
      94             :   }
      95           0 :   return ret;
      96             : }
      97             : 
      98             : 
      99             : /* end of taler-exchange-httpd_mhd.c */

Generated by: LCOV version 1.14