mirror of
https://github.com/pi-hole/FTL.git
synced 2024-10-26 16:52:18 +02:00
9ec7bd8722
Uses cJSON to parse, but output will still be handled directly. I implemented different API response methods to allow for different HTTP response codes to be sent. The addList code is still dumb and doesn't do anything, but it's getting there. Signed-off-by: Mcat12 <newtoncat12@yahoo.com>
31 lines
859 B
C
31 lines
859 B
C
/* Pi-hole: A black hole for Internet advertisements
|
|
* (c) 2017 Pi-hole, LLC (https://pi-hole.net)
|
|
* Network-wide ad blocking via your own hardware.
|
|
*
|
|
* FTL Engine
|
|
* General API commands
|
|
*
|
|
* This file is copyright under the latest version of the EUPL.
|
|
* Please see LICENSE file for your rights under this license. */
|
|
|
|
#include "FTL.h"
|
|
#include "api.h"
|
|
|
|
void sendAPIResponse(int sock, char type, char *http_status) {
|
|
if(type == APIH)
|
|
{
|
|
// Send header only for full HTTP requests
|
|
ssend(sock,
|
|
"HTTP/1.0 %s\nServer: FTL\nCache-Control: no-cache\nAccess-Control-Allow-Origin: *\n"
|
|
"Content-Type: application/json\n\n{", http_status);
|
|
}
|
|
}
|
|
|
|
void sendAPIResponseOK(int sock, char type) {
|
|
sendAPIResponse(sock, type, "200 OK");
|
|
}
|
|
|
|
void sendAPIResponseBadRequest(int sock, char type) {
|
|
sendAPIResponse(sock, type, "400 Bad Request");
|
|
}
|