Skip to content

Commit 116da18

Browse files
d-a-vearlephilhower
authored andcommitted
update HTTPCLIENT_1_1_COMPATIBLE (#5389)
* update HTTPCLIENT_1_1_COMPATIBLE: #if instead if #ifdef, set to 1 by default host emulation updates * host CI: minor simplification * revert -j
1 parent 4f86a68 commit 116da18

File tree

5 files changed

+41
-20
lines changed

5 files changed

+41
-20
lines changed

libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.cpp

+10-10
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,15 @@
2525

2626
#include "ESP8266HTTPClient.h"
2727

28-
#ifdef HTTPCLIENT_1_1_COMPATIBLE
28+
#if HTTPCLIENT_1_1_COMPATIBLE
2929
#include <ESP8266WiFi.h>
3030
#include <WiFiClientSecure.h>
3131
#endif
3232

3333
#include <StreamString.h>
3434
#include <base64.h>
3535

36-
#ifdef HTTPCLIENT_1_1_COMPATIBLE
36+
#if HTTPCLIENT_1_1_COMPATIBLE
3737
class TransportTraits
3838
{
3939
public:
@@ -112,7 +112,7 @@ class BearSSLTraits : public TransportTraits
112112
HTTPClient::HTTPClient()
113113
{
114114
_client = nullptr;
115-
#ifdef HTTPCLIENT_1_1_COMPATIBLE
115+
#if HTTPCLIENT_1_1_COMPATIBLE
116116
_tcpDeprecated.reset(nullptr);
117117
#endif
118118
}
@@ -147,7 +147,7 @@ void HTTPClient::clear()
147147
* @return success bool
148148
*/
149149
bool HTTPClient::begin(WiFiClient &client, String url) {
150-
#ifdef HTTPCLIENT_1_1_COMPATIBLE
150+
#if HTTPCLIENT_1_1_COMPATIBLE
151151
if(_tcpDeprecated) {
152152
DEBUG_HTTPCLIENT("[HTTP-Client][begin] mix up of new and deprecated api\n");
153153
_canReuse = false;
@@ -186,7 +186,7 @@ bool HTTPClient::begin(WiFiClient &client, String url) {
186186
*/
187187
bool HTTPClient::begin(WiFiClient &client, String host, uint16_t port, String uri, bool https)
188188
{
189-
#ifdef HTTPCLIENT_1_1_COMPATIBLE
189+
#if HTTPCLIENT_1_1_COMPATIBLE
190190
if(_tcpDeprecated) {
191191
DEBUG_HTTPCLIENT("[HTTP-Client][begin] mix up of new and deprecated api\n");
192192
_canReuse = false;
@@ -205,7 +205,7 @@ bool HTTPClient::begin(WiFiClient &client, String host, uint16_t port, String ur
205205
}
206206

207207

208-
#ifdef HTTPCLIENT_1_1_COMPATIBLE
208+
#if HTTPCLIENT_1_1_COMPATIBLE
209209
bool HTTPClient::begin(String url, String httpsFingerprint)
210210
{
211211
if(_client && !_tcpDeprecated) {
@@ -317,7 +317,7 @@ bool HTTPClient::beginInternal(String url, const char* expectedProtocol)
317317
return true;
318318
}
319319

320-
#ifdef HTTPCLIENT_1_1_COMPATIBLE
320+
#if HTTPCLIENT_1_1_COMPATIBLE
321321
bool HTTPClient::begin(String host, uint16_t port, String uri)
322322
{
323323
if(_client && !_tcpDeprecated) {
@@ -423,7 +423,7 @@ void HTTPClient::disconnect()
423423
_client->stop();
424424
_client = nullptr;
425425
}
426-
#ifdef HTTPCLIENT_1_1_COMPATIBLE
426+
#if HTTPCLIENT_1_1_COMPATIBLE
427427
if(_tcpDeprecated) {
428428
_transportTraits.reset(nullptr);
429429
_tcpDeprecated.reset(nullptr);
@@ -1035,7 +1035,7 @@ bool HTTPClient::connect(void)
10351035
return true;
10361036
}
10371037

1038-
#ifdef HTTPCLIENT_1_1_COMPATIBLE
1038+
#if HTTPCLIENT_1_1_COMPATIBLE
10391039
if(!_client && _transportTraits) {
10401040
_tcpDeprecated = _transportTraits->create();
10411041
_client = _tcpDeprecated.get();
@@ -1056,7 +1056,7 @@ bool HTTPClient::connect(void)
10561056

10571057
DEBUG_HTTPCLIENT("[HTTP-Client] connected to %s:%u\n", _host.c_str(), _port);
10581058

1059-
#ifdef HTTPCLIENT_1_1_COMPATIBLE
1059+
#if HTTPCLIENT_1_1_COMPATIBLE
10601060
if (_tcpDeprecated && !_transportTraits->verify(*_tcpDeprecated, _host.c_str())) {
10611061
DEBUG_HTTPCLIENT("[HTTP-Client] transport level verify failed\n");
10621062
_client->stop();

libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.h

+6-4
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@
2626
#ifndef ESP8266HTTPClient_H_
2727
#define ESP8266HTTPClient_H_
2828

29-
#define HTTPCLIENT_1_1_COMPATIBLE
29+
#ifndef HTTPCLIENT_1_1_COMPATIBLE
30+
#define HTTPCLIENT_1_1_COMPATIBLE 1
31+
#endif
3032

3133
#include <memory>
3234
#include <Arduino.h>
@@ -128,7 +130,7 @@ typedef enum {
128130
HTTPC_TE_CHUNKED
129131
} transferEncoding_t;
130132

131-
#ifdef HTTPCLIENT_1_1_COMPATIBLE
133+
#if HTTPCLIENT_1_1_COMPATIBLE
132134
class TransportTraits;
133135
typedef std::unique_ptr<TransportTraits> TransportTraitsPtr;
134136
#endif
@@ -148,7 +150,7 @@ class HTTPClient
148150
bool begin(WiFiClient &client, String url);
149151
bool begin(WiFiClient &client, String host, uint16_t port, String uri = "/", bool https = false);
150152

151-
#ifdef HTTPCLIENT_1_1_COMPATIBLE
153+
#if HTTPCLIENT_1_1_COMPATIBLE
152154
// Plain HTTP connection, unencrypted
153155
bool begin(String url) __attribute__ ((deprecated));
154156
bool begin(String host, uint16_t port, String uri = "/") __attribute__ ((deprecated));
@@ -222,7 +224,7 @@ class HTTPClient
222224
int writeToStreamDataBlock(Stream * stream, int len);
223225

224226

225-
#ifdef HTTPCLIENT_1_1_COMPATIBLE
227+
#if HTTPCLIENT_1_1_COMPATIBLE
226228
TransportTraitsPtr _transportTraits;
227229
std::unique_ptr<WiFiClient> _tcpDeprecated;
228230
#endif

tests/common.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ function build_docs()
134134
function run_host_tests()
135135
{
136136
pushd host
137-
make FORCE32=0 OPTZ=-O0 CI
137+
make CI
138138
make clean-objects
139139
popd
140140
}

tests/host/Makefile

+12-5
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,10 @@ DEBUG += -DDEBUG_ESP_PORT=Serial
120120
DEBUG += -DDEBUG_ESP_SSL -DDEBUG_ESP_TLS_MEM -DDEBUG_ESP_HTTP_CLIENT -DDEBUG_ESP_HTTP_SERVER -DDEBUG_ESP_CORE -DDEBUG_ESP_WIFI -DDEBUG_ESP_HTTP_UPDATE -DDEBUG_ESP_UPDATER -DDEBUG_ESP_OTA -DDEBUG_ESP_MDNS
121121
endif
122122

123-
FLAGS += $(DEBUG) -Wall -Werror -coverage $(OPTZ) -fno-common -g $(M32)
123+
FLAGS += $(DEBUG) -Wall -coverage $(OPTZ) -fno-common -g $(M32)
124+
FLAGS += -DHTTPCLIENT_1_1_COMPATIBLE=0
124125
FLAGS += -DLWIP_IPV6=0
126+
FLAGS += $(MKFLAGS)
125127
CXXFLAGS += -std=c++11 $(FLAGS)
126128
CFLAGS += -std=c99 $(FLAGS)
127129
LDFLAGS += -coverage $(OPTZ) -g $(M32)
@@ -145,7 +147,10 @@ COVERAGE_FILES = $(OBJECTS:.o=.gc*)
145147

146148
all: help
147149

148-
CI: build-info $(OUTPUT_BINARY) valgrind test gcov # run CI
150+
CI:
151+
$(MAKE) -f $(MAKEFILE) MKFLAGS=-Werror FORCE32=0 OPTZ=-O0 doCI
152+
153+
doCI: build-info $(OUTPUT_BINARY) valgrind test gcov # run CI
149154

150155
test: $(OUTPUT_BINARY) # run host test for CI
151156
$(OUTPUT_BINARY)
@@ -203,6 +208,7 @@ ARDUINO_LIBS := \
203208
$(addprefix $(CORE_PATH)/,\
204209
IPAddress.cpp \
205210
Updater.cpp \
211+
base64.cpp \
206212
) \
207213
$(addprefix ../../libraries/,\
208214
$(addprefix ESP8266WiFi/src/,\
@@ -263,6 +269,7 @@ ULIBPATHS = $(shell echo $(ULIBDIRS) | sed 's,:, ,g')
263269
USERLIBDIRS = $(shell test -z "$(ULIBPATHS)" || for d in $(ULIBPATHS); do for dd in $$d $$d/src; do test -d $$dd && { echo -I$$dd; echo "userlib: using directory '$$dd'" 1>&2; } done; done)
264270
USERLIBSRCS = $(shell test -z "$(ULIBPATHS)" || for d in $(ULIBPATHS); do for ss in $$d/*.cpp $$d/src/*.cpp; do test -r $$ss && echo $$ss; done; done)
265271
INC_PATHS += $(USERLIBDIRS)
272+
INC_PATHS += -I$(INODIR)/..
266273
CPP_OBJECTS_CORE_EMU = $(CPP_SOURCES_CORE_EMU:.cpp=.cpp.o) $(USERLIBSRCS:.cpp=.cpp.o)
267274

268275
bin/fullcore.a: $(C_OBJECTS) $(CPP_OBJECTS_CORE_EMU)
@@ -279,18 +286,18 @@ ifeq ($(INO),)
279286

280287
%: %.ino
281288
@# recursive 'make' with paths
282-
$(MAKE) -f $(MAKEFILE) INODIR=$(dir $@) INO=$(notdir $@) $(BINDIR)/$(notdir $@)/$(notdir $@)
289+
$(MAKE) -f $(MAKEFILE) MKFLAGS=-Wextra INODIR=$(dir $@) INO=$(notdir $@) $(BINDIR)/$(notdir $@)/$(notdir $@)
283290
@# see below the new build rule with fixed output path outside from core location
284291

285292
#####################
286-
# recursive call on ino targer
293+
# recursive call on ino target
287294
else
288295

289296
$(BINDIR)/$(INO)/$(INO).ino.cpp:
290297
@# arduino builder would come around here (.ino -> .ino.cpp)
291298
@mkdir -p $(BINDIR)/$(INO); \
292299
( \
293-
echo "#include \"$(INODIR)/$(INO).ino\""; \
300+
echo "#include <$(INODIR)/$(INO).ino>"; \
294301
for i in $(INODIR)/*.ino; do \
295302
test "$$i" = $(INODIR)/$(INO).ino || echo "#include \"$$i\""; \
296303
done; \

tests/host/common/mock.h

+12
Original file line numberDiff line numberDiff line change
@@ -118,4 +118,16 @@ class InterruptLock { };
118118

119119
//
120120

121+
#define D0 0
122+
#define D1 1
123+
#define D2 3
124+
#define D3 3
125+
#define D4 4
126+
#define D5 5
127+
#define D6 6
128+
#define D7 7
129+
#define D8 8
130+
131+
//
132+
121133
#endif // __cplusplus

0 commit comments

Comments
 (0)