From ccfd7d6ba21e75596df1c830de602ecdd6d80329 Mon Sep 17 00:00:00 2001 From: Mochigome <106659178+mochigome-git@users.noreply.github.com> Date: Wed, 29 Nov 2023 09:53:24 +0800 Subject: [PATCH 1/2] Update HttpClient.h --- src/HttpClient.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/HttpClient.h b/src/HttpClient.h index 6a7aa1d..3fbd18f 100644 --- a/src/HttpClient.h +++ b/src/HttpClient.h @@ -211,6 +211,8 @@ class HttpClient : public Client void sendBasicAuth(const String& aUser, const String& aPassword) { sendBasicAuth(aUser.c_str(), aPassword.c_str()); } + void sendApiKeyHeader(const char* apiKey); + /** Get the HTTP status code contained in the response. For example, 200 for successful request, 404 for file not found, etc. */ From f144d0a41b6fb925a5a2f273a461fa724735998c Mon Sep 17 00:00:00 2001 From: Mochigome <106659178+mochigome-git@users.noreply.github.com> Date: Wed, 29 Nov 2023 09:54:59 +0800 Subject: [PATCH 2/2] Update HttpClient.cpp --- src/HttpClient.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/HttpClient.cpp b/src/HttpClient.cpp index 1c73464..973d172 100644 --- a/src/HttpClient.cpp +++ b/src/HttpClient.cpp @@ -63,6 +63,16 @@ void HttpClient::beginRequest() iState = eRequestStarted; } +void HttpClient::sendApiKeyHeader(const char* apiKey) { + if (iState < eRequestSent) { + finishHeaders(); + } + + String header = "apikey: "; + header += apiKey; + sendHeader(header); +} + int HttpClient::startRequest(const char* aURLPath, const char* aHttpMethod, const char* aContentType, int aContentLength, const byte aBody[]) {