paivana

HTTP paywall reverse proxy
Log | Files | Refs | Submodules | README | LICENSE

paivana-httpd_reverse.h (2947B)


      1 /*
      2      This file is part of GNUnet.
      3      Copyright (C) 2026 Taler Systems SA
      4 
      5      Paivana is free software; you can redistribute it and/or
      6      modify it under the terms of the GNU Affero General Public License
      7      as published by the Free Software Foundation; either version
      8      3, or (at your option) any later version.
      9 
     10      Paivana is distributed in the hope that it will be useful,
     11      but WITHOUT ANY WARRANTY; without even the implied warranty
     12      of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
     13      the GNU Affero General Public License for more details.
     14 
     15      You should have received a copy of the GNU Affero General Public
     16      License along with Paivana; see the file COPYING.  If not,
     17      write to the Free Software Foundation, Inc., 51 Franklin
     18      Street, Fifth Floor, Boston, MA 02110-1301, USA.
     19 */
     20 
     21 /**
     22  * @author Christian Grothoff
     23  * @file paivana-httpd_reverse.h
     24  *
     25  * @brief Project data definition
     26  */
     27 #ifndef PAIVANA_HTTPD_REVERSE_H
     28 #define PAIVANA_HTTPD_REVERSE_H
     29 
     30 #include <gnunet/gnunet_util_lib.h>
     31 #include <microhttpd.h>
     32 #include "paivana-httpd.h"
     33 
     34 bool
     35 PAIVANA_HTTPD_reverse_init (void);
     36 
     37 
     38 void
     39 PAIVANA_HTTPD_reverse_shutdown (void);
     40 
     41 
     42 struct HttpRequest *
     43 PAIVANA_HTTPD_reverse_create (struct MHD_Connection *connection,
     44                               const char *url);
     45 
     46 /**
     47  * Main MHD callback for reverse proxy.
     48  *
     49  * @param hr the HTTP request context
     50  * @param con MHD connection handle
     51  * @param url the url in the request (unused; the URL to forward was
     52  *        captured by #PAIVANA_HTTPD_reverse_create() and is kept in
     53  *        @a hr, but the parameter is retained to mirror the MHD
     54  *        access handler's signature)
     55  * @param meth the HTTP method used ("GET", "PUT", etc.)
     56  * @param ver the HTTP version string (i.e. "HTTP/1.1")
     57  * @param upload_data the data being uploaded (excluding HEADERS,
     58  *        for a POST that fits into memory and that is encoded
     59  *        with a supported encoding, the POST data will NOT be
     60  *        given in upload_data and is instead available as
     61  *        part of MHD_get_connection_values; very large POST
     62  *        data *will* be made available incrementally in
     63  *        upload_data)
     64  * @param upload_data_size set initially to the size of the
     65  *        @a upload_data provided; the method must update this
     66  *        value to the number of bytes NOT processed;
     67  * @return #MHD_YES if the connection was handled successfully,
     68  *         #MHD_NO if the socket must be closed due to a serious
     69  *         error while handling the request
     70  */
     71 enum MHD_Result
     72 PAIVANA_HTTPD_reverse (struct HttpRequest *hr,
     73                        struct MHD_Connection *con,
     74                        const char *url,
     75                        const char *meth,
     76                        const char *ver,
     77                        const char *upload_data,
     78                        size_t *upload_data_size);
     79 
     80 
     81 void
     82 PAIVANA_HTTPD_reverse_cleanup (struct HttpRequest *hr);
     83 
     84 #endif