mirror of
https://github.com/pi-hole/FTL.git
synced 2024-10-26 16:52:18 +02:00
8742e140c0
Signed-off-by: DL6ER <dl6er@dl6er.de>
56 lines
1.8 KiB
C
56 lines
1.8 KiB
C
/* Pi-hole: A black hole for Internet advertisements
|
|
* (c) 2019 Pi-hole, LLC (https://pi-hole.net)
|
|
* Network-wide ad blocking via your own hardware.
|
|
*
|
|
* FTL Engine
|
|
* HTTP server routines
|
|
*
|
|
* This file is copyright under the latest version of the EUPL.
|
|
* Please see LICENSE file for your rights under this license. */
|
|
#ifndef HTTP_H
|
|
#define HTTP_H
|
|
|
|
// External components
|
|
#include "../civetweb/civetweb.h"
|
|
#include "../cJSON/cJSON.h"
|
|
|
|
// strlen()
|
|
#include <string.h>
|
|
|
|
// FTLfree()
|
|
#include "../memory.h"
|
|
|
|
void http_init(void);
|
|
void http_terminate(void);
|
|
|
|
int send_http(struct mg_connection *conn, const char *mime_type, const char *msg);
|
|
int send_http_code(struct mg_connection *conn, const char *mime_type, int code, const char *msg);
|
|
int send_http_internal_error(struct mg_connection *conn);
|
|
int send_json_unauthorized(struct mg_connection *conn);
|
|
int send_json_error(struct mg_connection *conn, const int code,
|
|
const char *key, const char* message,
|
|
cJSON *data);
|
|
int send_json_success(struct mg_connection *conn);
|
|
|
|
void http_reread_index_html(void);
|
|
|
|
// Cookie routines
|
|
bool http_get_cookie_int(struct mg_connection *conn, const char *cookieName, int *i);
|
|
bool http_get_cookie_str(struct mg_connection *conn, const char *cookieName, char *str, size_t str_size);
|
|
|
|
// HTTP parameter routines
|
|
bool get_bool_var(const char *source, const char *var);
|
|
int get_int_var(const char *source, const char *var);
|
|
|
|
// HTTP macros
|
|
#define GET_VAR(variable, destination, source) mg_get_var(source, strlen(source), variable, destination, sizeof(destination))
|
|
|
|
// Method routines
|
|
enum { HTTP_UNKNOWN, HTTP_GET, HTTP_POST, HTTP_DELETE };
|
|
int http_method(struct mg_connection *conn);
|
|
|
|
// Utils
|
|
bool startsWith(const char *path, const char *uri) __attribute__((pure));
|
|
|
|
#endif // HTTP_H
|