8000 update HTTPCLIENT_1_1_COMPATIBLE by d-a-v · Pull Request #5389 · esp8266/Arduino · GitHub
[go: up one dir, main page]

Skip to content

update HTTPCLIENT_1_1_COMPATIBLE #5389

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Nov 29, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
update HTTPCLIENT_1_1_COMPATIBLE: #if instead if #ifdef, set to 1 by …
…default

host emulation updates
  • Loading branch information
d-a-v committed Nov 29, 2018
commit 7c9f9c94c63558afdcf00679eec5da76475db9db
20 changes: 10 additions & 10 deletions libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@

#include "ESP8266HTTPClient.h"

#ifdef HTTPCLIENT_1_1_COMPATIBLE
#if HTTPCLIENT_1_1_COMPATIBLE
#include <ESP8266WiFi.h>
#include <WiFiClientSecure.h>
#endif

#include <StreamString.h>
#include <base64.h>

#ifdef HTTPCLIENT_1_1_COMPATIBLE
#if HTTPCLIENT_1_1_COMPATIBLE
class TransportTraits
{
public:
Expand Down Expand Up @@ -112,7 +112,7 @@ class BearSSLTraits : public TransportTraits
HTTPClient::HTTPClient()
{
_client = nullptr;
#ifdef HTTPCLIENT_1_1_COMPATIBLE
#if HTTPCLIENT_1_1_COMPATIBLE
_tcpDeprecated.reset(nullptr);
#endif
}
Expand Down Expand Up @@ -147,7 +147,7 @@ void HTTPClient::clear()
* @return success bool
*/
bool HTTPClient::begin(WiFiClient &client, String url) {
#ifdef HTTPCLIENT_1_1_COMPATIBLE
#if HTTPCLIENT_1_1_COMPATIBLE
if(_tcpDeprecated) {
DEBUG_HTTPCLIENT("[HTTP-Client][begin] mix up of new and deprecated api\n");
_canReuse = false;
Expand Down Expand Up @@ -186,7 +186,7 @@ bool HTTPClient::begin(WiFiClient &client, String url) {
*/
bool HTTPClient::begin(WiFiClient &client, String host, uint16_t port, String uri, bool https)
{
#ifdef HTTPCLIENT_1_1_COMPATIBLE
#if HTTPCLIENT_1_1_COMPATIBLE
if(_tcpDeprecated) {
DEBUG_HTTPCLIENT("[HTTP-Client][begin] mix up of new and deprecated api\n");
_canReuse = false;
Expand All @@ -205,7 +205,7 @@ bool HTTPClient::begin(WiFiClient &client, String host, uint16_t port, String ur
}


#ifdef HTTPCLIENT_1_1_COMPATIBLE
#if HTTPCLIENT_1_1_COMPATIBLE
bool HTTPClient::begin(String url, String httpsFingerprint)
{
if(_client && !_tcpDeprecated) {
Expand Down Expand Up @@ -317,7 +317,7 @@ bool HTTPClient::beginInternal(String url, const char* expectedProtocol)
return true;
}

#ifdef HTTPCLIENT_1_1_COMPATIBLE
#if HTTPCLIENT_1_1_COMPATIBLE
bool HTTPClient::begin(String host, uint16_t port, String uri)
{
if(_client && !_tcpDeprecated) {
Expand Down Expand Up @@ -423,7 +423,7 @@ void HTTPClient::disconnect()
_client->stop();
_client = nullptr;
}
#ifdef HTTPCLIENT_1_1_COMPATIBLE
#if HTTPCLIENT_1_1_COMPATIBLE
if(_tcpDep 8000 recated) {
_transportTraits.reset(nullptr);
_tcpDeprecated.reset(nullptr);
Expand Down Expand Up @@ -1035,7 +1035,7 @@ bool HTTPClient::connect(void)
return true;
}

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

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

#ifdef HTTPCLIENT_1_1_COMPATIBLE
#if HTTPCLIENT_1_1_COMPATIBLE
if (_tcpDeprecated && !_transportTraits->verify(*_tcpDeprecated, _host.c_str())) {
DEBUG_HTTPCLIENT("[HTTP-Client] transport level verify failed\n");
_client->stop();
Expand Down
10 changes: 6 additions & 4 deletions libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@
#ifndef ESP8266HTTPClient_H_
#define ESP8266HTTPClient_H_

#define HTTPCLIENT_1_1_COMPATIBLE
#ifndef HTTPCLIENT_1_1_COMPATIBLE
#define HTTPCLIENT_1_1_COMPATIBLE 1
#endif

#include <memory>
#include <Arduino.h>
Expand Down Expand Up @@ -128,7 +130,7 @@ typedef enum {
HTTPC_TE_CHUNKED
} transferEncoding_t;

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

#ifdef HTTPCLIENT_1_1_COMPATIBLE
#if HTTPCLIENT_1_1_COMPATIBLE
// Plain HTTP connection, unencrypted
bool begin(String url) __attribute__ ((deprecated));
bool begin(String host, uint16_t port, String uri = "/") __attribute__ ((deprecated));
Expand Down Expand Up @@ -222,7 +224,7 @@ class HTTPClient
int writeToStreamDataBlock(Stream * stream, int len);


#ifdef HTTPCLIENT_1_1_COMPATIBLE
#if HTTPCLIENT_1_1_COMPATIBLE
TransportTraitsPtr _transportTraits;
8000 std::unique_ptr<WiFiClient> _tcpDeprecated;
#endif
Expand Down
17 changes: 12 additions & 5 deletions tests/host/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,10 @@ DEBUG += -DDEBUG_ESP_PORT=Serial
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
endif

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

all: help

CI: build-info $(OUTPUT_BINARY) valgrind test gcov # run CI
CI:
$(MAKE) -f $(MAKEFILE) MKFLAGS=-Werror FORCE32=0 OPTZ=-O0 doCI

doCI: build-info $(OUTPUT_BINARY) valgrind test gcov # run CI

test: $(OUTPUT_BINARY) # run host test for CI
$(OUTPUT_BINARY)
Expand Down Expand Up @@ -203,6 +208,7 @@ ARDUINO_LIBS := \
$(addprefix $(CORE_PATH)/,\
IPAddress.cpp \
Updater.cpp \
base64.cpp \
) \
$(addprefix ../../libraries/,\
$(addprefix ESP8266WiFi/src/,\
Expand Down Expand Up @@ -263,6 +269,7 @@ ULIBPATHS = $(shell echo $(ULIBDIRS) | sed 's,:, ,g')
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)
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)
INC_PATHS += $(USERLIBDIRS)
INC_PATHS += -I$(INODIR)/..
CPP_OBJECTS_CORE_EMU = $(CPP_SOURCES_CORE_EMU:.cpp=.cpp.o) $(USERLIBSRCS:.cpp=.cpp.o)

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

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

#####################
# recursive call on ino targer
# recursive call on ino target
else

$(BINDIR)/$(INO)/$(INO).ino.cpp:
@# arduino builder would come around here (.ino -> .ino.cpp)
@mkdir -p $(BINDIR)/$(INO); \
( \
echo "#include \"$(INODIR)/$(INO).ino\""; \
echo "#include <$(INODIR)/$(INO).ino>"; \
for i in $(INODIR)/*.ino; do \
test "$$i" = $(INODIR)/$(INO).ino || echo "#include \"$$i\""; \
done; \
Expand Down
18 changes: 9 additions & 9 deletions tests/host/README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Show the core example list:


Build one example
make D=1 ../../libraries/esp8266/examples/Blink/Blink
make -j D=1 ../../libraries/esp8266/examples/Blink/Blink
run it:
./bin/Blink/Blink -h

Expand All @@ -41,19 +41,19 @@ Optional 'FORCE32=0' will use native/default gcc (default is FORCE32=1 unless gc


Non exhaustive list of working examples:
make D=1 ../../libraries/ESP8266WiFi/examples/udp/udp
make D=1 ../../libraries/ESP8266WiFi/examples/WiFiClient/WiFiClient
make D=1 ../../libraries/ESP8266WebServer/examples/HelloServer/HelloServer
make D=1 ../../libraries/ESP8266WebServer/examples/AdvancedWebServer/AdvancedWebServer
make D=1 ../../libraries/ESP8266mDNS/examples/mDNS_Web_Server/mDNS_Web_Server
make D=1 ../../libraries/ESP8266WiFi/examples/BearSSL_Validation/BearSSL_Validation
make -j D=1 ../../libraries/ESP8266WiFi/examples/udp/udp
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I remember saying -j would auto-scale the jobs, but it turns out I was wrong. -j will run as many jobs in parallel as make can figure out. It's not really an issue for a single compile like this as most folks will have at least 2-4 cores if they're doing this.

-j [jobs], --jobs[=jobs]
     Specifies the number of jobs (commands) to run simultaneously.  If there is more
     than one -j option, the last one is effective.  If the -j option is given  with‐
     out  an argument, make will not limit the number of jobs that can run simultane‐
     ously. When make invokes a sub-make, all instances of make  will  coordinate  to
     run  the  specified  number of jobs at a time; see the section PARALLEL MAKE AND
     THE JOBSERVER for details.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I remember saying -j

I took your wise word :)

make -j D=1 ../../libraries/ESP8266WiFi/examples/WiFiClient/WiFiClient
make -j D=1 ../../libraries/ESP8266WebServer/examples/HelloServer/HelloServer
make -j D=1 ../../libraries/ESP8266WebServer/examples/AdvancedWebServer/AdvancedWebServer
make -j D=1 ../../libraries/ESP8266mDNS/examples/mDNS_Web_Server/mDNS_Web_Server
make -j D=1 ../../libraries/ESP8266WiFi/examples/BearSSL_Validation/BearSSL_Validation

Compile other sketches:
- library paths are specified using ULIBDIRS variable, separated by ':'
- call 'make path-to-the-sketch-file' to build (without its '.ino' extension):
- CAVEAT: functions must be declared *before* being called (arduino builder is not around)

make D=1 ULIBDIRS=/path/to/your/arduino/libraries/lib1:/path/to/another/place/lib2 /path/to/your/sketchdir/sketch/sketch
make -j D=1 ULIBDIRS=/path/to/your/arduino/libraries/lib1:/path/to/another/place/lib2 /path/to/your/sketchdir/sketch/sketch
or:
ULIBDIRS=/path/to/your/arduino/libraries/lib1:/path/to/another/place/lib2 make D=1 /path/to/your/sketchdir/sketch/sketch

Expand All @@ -62,7 +62,7 @@ Compile other sketches:
export D=1
export OPTZ=-O2
make clean
make /path/to/your/sketchdir/sketch/sketch
make -j /path/to/your/sketchdir/sketch/sketch
./bin/sketch/sketch


Expand Down
12 changes: 12 additions & 0 deletions tests/host/common/mock.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,4 +118,16 @@ class InterruptLock { };

//

#define D0 0
#define D1 1
#define D2 3
#define D3 3
#define D4 4
#define D5 5
#define D6 6
#define D7 7
#define D8 8

//

#endif // __cplusplus
0