From 204f360dce31649259102bb633c218216000bef8 Mon Sep 17 00:00:00 2001 From: long_long_float Date: Fri, 1 Oct 2021 21:04:09 +0900 Subject: [PATCH] Append '/' to an URL with empty path in HTTPClient::begin (#5634) * Add an error check for empty path of an URL * Append '/' to an URL with empty path instead of returning an error --- libraries/HTTPClient/src/HTTPClient.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libraries/HTTPClient/src/HTTPClient.cpp b/libraries/HTTPClient/src/HTTPClient.cpp index e7a8ecb8..cc0a31e2 100644 --- a/libraries/HTTPClient/src/HTTPClient.cpp +++ b/libraries/HTTPClient/src/HTTPClient.cpp @@ -261,6 +261,10 @@ bool HTTPClient::beginInternal(String url, const char* expectedProtocol) url.remove(0, (index + 3)); // remove http:// or https:// index = url.indexOf('/'); + if (index == -1) { + index = url.length(); + url += '/'; + } String host = url.substring(0, index); url.remove(0, index); // remove host part