From 2901f773a4ab3a279930853c74ad0a7eca1dcff1 Mon Sep 17 00:00:00 2001 From: Jm Casler Date: Fri, 16 Oct 2020 23:33:50 -0700 Subject: [PATCH] Some cleanup and implement the X-Protobuf-Schema header --- src/meshwifi/meshhttp.cpp | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/meshwifi/meshhttp.cpp b/src/meshwifi/meshhttp.cpp index 7f26800a..8e4cb4c7 100644 --- a/src/meshwifi/meshhttp.cpp +++ b/src/meshwifi/meshhttp.cpp @@ -343,6 +343,7 @@ void handleAPIv1FromRadio(HTTPRequest *req, HTTPResponse *res) res->setHeader("Content-Type", "application/x-protobuf"); res->setHeader("Access-Control-Allow-Origin", "*"); res->setHeader("Access-Control-Allow-Methods", "PUT, GET"); + res->setHeader("X-Protobuf-Schema", "https://raw.githubusercontent.com/meshtastic/Meshtastic-protobufs/master/mesh.proto"); uint8_t txBuf[MAX_STREAM_BUF_SIZE]; uint32_t len = 1; @@ -380,19 +381,14 @@ void handleAPIv1ToRadio(HTTPRequest *req, HTTPResponse *res) // Status code is 200 OK by default. - if (req->getMethod() != "OPTIONS") { - res->setHeader("Content-Type", "application/x-protobuf"); - } else { - res->setHeader("Content-Type", "application/x-protobuf"); - - } - + res->setHeader("Content-Type", "application/x-protobuf"); res->setHeader("Access-Control-Allow-Headers", "Content-Type"); res->setHeader("Access-Control-Allow-Origin", "*"); res->setHeader("Access-Control-Allow-Methods", "PUT, OPTIONS"); + res->setHeader("X-Protobuf-Schema", "https://raw.githubusercontent.com/meshtastic/Meshtastic-protobufs/master/mesh.proto"); if (req->getMethod() == "OPTIONS") { - res->setStatusCode(204); + res->setStatusCode(204); // Success with no content res->print(""); return; }