LCOV - code coverage report
Current view: top level - backend - taler-merchant-httpd_mhd.c (source / functions) Coverage Total Hit
Test: coverage.info Lines: 41.2 % 17 7
Test Date: 2025-10-24 18:15:31 Functions: 33.3 % 3 1

            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            0 :                                  rh->response_code,
      38            0 :                                  rh->mime_type,
      39            0 :                                  rh->data,
      40            0 :                                  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           33 : TMH_MHD_test_html_desired (struct MHD_Connection *connection)
      58              : {
      59              :   const char *accept;
      60              :   double json_q;
      61              :   double html_q;
      62              : 
      63           33 :   accept = MHD_lookup_connection_value (connection,
      64              :                                         MHD_HEADER_KIND,
      65              :                                         MHD_HTTP_HEADER_ACCEPT);
      66           33 :   if (NULL == accept)
      67            0 :     return false; /* nothing selected, we read this as not HTML */
      68           33 :   html_q = TALER_pattern_matches (accept,
      69              :                                   "text/html");
      70           33 :   json_q = TALER_pattern_matches (accept,
      71              :                                   "application/json");
      72           33 :   if (html_q > json_q)
      73            0 :     return true;
      74           33 :   return false;
      75              : }
      76              : 
      77              : 
      78              : /* end of taler-exchange-httpd_mhd.c */
        

Generated by: LCOV version 2.0-1