1 #ifndef SRC_HTTPCONNECTION_HPP_ 2 #define SRC_HTTPCONNECTION_HPP_ 7 #include <mbedtls/base64.h> 8 #include <hwcrypto/sha.h> 12 #include "lwip/netdb.h" 14 #include "lwip/sockets.h" 16 #include "HTTPSServerConstants.hpp" 17 #include "ConnectionContext.hpp" 19 #include "HTTPHeaders.hpp" 20 #include "HTTPHeader.hpp" 22 #include "ResourceResolver.hpp" 23 #include "ResolvedResource.hpp" 25 #include "ResourceNode.hpp" 26 #include "HTTPRequest.hpp" 27 #include "HTTPResponse.hpp" 29 #include "WebsocketHandler.hpp" 30 #include "WebsocketNode.hpp" 43 virtual void closeConnection();
44 virtual bool isSecure();
55 virtual size_t writeBuffer(byte* buffer,
size_t length);
56 virtual size_t readBytesToBuffer(byte* buffer,
size_t length);
57 virtual bool canReadData();
58 virtual size_t pendingByteCount();
61 unsigned long _lastTransmissionTS;
64 unsigned long _shutdownTS;
88 STATE_REQUEST_FINISHED,
90 STATE_HEADERS_FINISHED,
112 void readLine(
int lengthLimit);
114 bool isTimeoutExceeded();
115 void refreshTimeout();
118 size_t pendingBufferSize();
120 void signalClientClose();
121 void signalRequestError();
122 size_t readBuffer(byte* buffer,
size_t length);
123 size_t getCacheSize();
124 bool checkWebsocket();
127 char _receiveBuffer[HTTPS_CONNECTION_DATA_CHUNK_SIZE];
130 int _bufferProcessed;
132 int _bufferUnusedIdx;
135 struct sockaddr _sockAddr;
144 std::string text =
"";
145 bool parsingFinished =
false;
149 std::string _httpMethod;
150 std::string _httpResource;
void handleWebsocketHandshake(HTTPRequest *req, HTTPResponse *res)
Definition: HTTPConnection.cpp:624
Represents the request stream for an HTTP request.
Definition: HTTPRequest.hpp:21
Represents the response stream of an HTTP request.
Definition: HTTPResponse.hpp:25
void validationMiddleware(HTTPRequest *req, HTTPResponse *res, std::function< void()> next)
Definition: HTTPConnection.cpp:598
bool isError()
Definition: HTTPConnection.cpp:88
Definition: WebsocketHandler.hpp:34
This class is used internally to resolve a string URL to the corresponding HTTPNode.
Definition: ResourceResolver.hpp:22
Internal class to handle the state of a connection.
Definition: ConnectionContext.hpp:17
Represents a single open connection for the plain HTTPServer, without TLS.
Definition: HTTPConnection.hpp:37
bool isClosed()
Definition: HTTPConnection.cpp:81
std::string websocketKeyResponseHash(std::string const &key)
Definition: HTTPConnection.cpp:636
virtual int initialize(int serverSocketID, HTTPHeaders *defaultHeaders)
Definition: HTTPConnection.cpp:33
Definition: ConnectionContext.cpp:3