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: 18 25 72.0 %
Date: 2021-08-30 06:54:17 Functions: 1 3 33.3 %
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          60 : TMH_MHD_test_html_desired (struct MHD_Connection *connection)
      58             : {
      59          60 :   bool ret = false;
      60             :   const char *accept;
      61             : 
      62          60 :   accept = MHD_lookup_connection_value (connection,
      63             :                                         MHD_HEADER_KIND,
      64             :                                         MHD_HTTP_HEADER_ACCEPT);
      65          60 :   if (NULL != accept)
      66             :   {
      67          60 :     char *a = GNUNET_strdup (accept);
      68             :     char *saveptr;
      69             : 
      70         197 :     for (char *t = strtok_r (a, ",", &saveptr);
      71             :          NULL != t;
      72         137 :          t = strtok_r (NULL, ",", &saveptr))
      73             :     {
      74             :       char *end;
      75             : 
      76             :       /* skip leading whitespace */
      77         228 :       while (isspace ((unsigned char) t[0]))
      78          84 :         t++;
      79             :       /* trim of ';q=' parameter and everything after space */
      80         144 :       end = strchr (t, ';');
      81         144 :       if (NULL != end)
      82           0 :         *end = '\0';
      83         144 :       end = strchr (t, ' ');
      84         144 :       if (NULL != end)
      85           0 :         *end = '\0';
      86         144 :       if (0 == strcasecmp ("text/html",
      87             :                            t))
      88             :       {
      89           7 :         ret = true;
      90           7 :         break;
      91             :       }
      92             :     }
      93          60 :     GNUNET_free (a);
      94             :   }
      95          60 :   return ret;
      96             : }
      97             : 
      98             : 
      99             : /* end of taler-exchange-httpd_mhd.c */

Generated by: LCOV version 1.14