Skip to content
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

Fixed compiling with ESP32 + bug fix #142

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
20 changes: 10 additions & 10 deletions src/HTTPConnection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ HTTPConnection::HTTPConnection(ResourceResolver * resResolver):
_clientState = CSTATE_UNDEFINED;
_httpHeaders = NULL;
_defaultHeaders = NULL;
_isKeepAlive = false;
_isKeepAlive = true;
_lastTransmissionTS = millis();
_shutdownTS = 0;
_wsHandler = nullptr;
Expand Down Expand Up @@ -44,9 +44,9 @@ int HTTPConnection::initialize(int serverSocketID, HTTPHeaders *defaultHeaders)
refreshTimeout();
return _socket;
}

HTTPS_LOGE("Could not accept() new connection");

_addrLen = 0;
_connectionState = STATE_ERROR;
_clientState = CSTATE_ACTIVE;
Expand Down Expand Up @@ -452,15 +452,15 @@ void HTTPConnection::loop() {
[](unsigned char c){ return ::tolower(c); }
);
}
if (std::string("keep-alive").compare(connectionHeaderValue)==0) {
HTTPS_LOGD("Keep-Alive activated. FID=%d", _socket);
_isKeepAlive = true;
} else {
if (std::string("close").compare(connectionHeaderValue)==0) {
HTTPS_LOGD("Keep-Alive disabled. FID=%d", _socket);
_isKeepAlive = false;
} else {
HTTPS_LOGD("Keep-Alive activated. FID=%d", _socket);
_isKeepAlive = true;
}
} else {
_isKeepAlive = false;
_isKeepAlive = true;
}

// Create request context
Expand Down Expand Up @@ -520,7 +520,7 @@ void HTTPConnection::loop() {
// Finally, after the handshake is done, we create the WebsocketHandler and change the internal state.
if(websocketRequested) {
_wsHandler = ((WebsocketNode*)resolvedResource.getMatchingNode())->newHandler();
_wsHandler->initialize(this); // make websocket with this connection
_wsHandler->initialize(this); // make websocket with this connection
_connectionState = STATE_WEBSOCKET;
} else {
// Handling the request is done
Expand Down Expand Up @@ -680,7 +680,7 @@ std::string websocketKeyResponseHash(std::string const &key) {
(const unsigned char*)shaData,
HTTPS_SHA1_LENGTH
);

// Check result and return the encoded string
if (res != 0) {
return std::string();
Expand Down
4 changes: 4 additions & 0 deletions src/HTTPConnection.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@

#include <string>
#include <mbedtls/base64.h>
#ifdef ESP32
#include <sha/sha_parallel_engine.h>
#else
#include <hwcrypto/sha.h>
#endif
#include <functional>

// Required for sockets
Expand Down