1 #ifndef SRC_HTTPCONNECTION_HPP_ 2 #define SRC_HTTPCONNECTION_HPP_ 8 #include <mbedtls/base64.h> 9 #include <hwcrypto/sha.h> 13 #include "lwip/netdb.h" 15 #include "lwip/sockets.h" 17 #include "HTTPSServerConstants.hpp" 18 #include "ConnectionContext.hpp" 20 #include "HTTPHeaders.hpp" 21 #include "HTTPHeader.hpp" 23 #include "ResourceResolver.hpp" 24 #include "ResolvedResource.hpp" 26 #include "ResourceNode.hpp" 27 #include "HTTPRequest.hpp" 28 #include "HTTPResponse.hpp" 30 #include "WebsocketHandler.hpp" 31 #include "WebsocketNode.hpp" 44 virtual void closeConnection();
45 virtual bool isSecure();
57 virtual size_t writeBuffer(byte* buffer,
size_t length);
58 virtual size_t readBytesToBuffer(byte* buffer,
size_t length);
59 virtual bool canReadData();
60 virtual size_t pendingByteCount();
63 unsigned long _lastTransmissionTS;
66 unsigned long _shutdownTS;
90 STATE_REQUEST_FINISHED,
92 STATE_HEADERS_FINISHED,
112 void raiseError(uint16_t code, std::string reason);
113 void readLine(
int lengthLimit);
115 bool isTimeoutExceeded();
116 void refreshTimeout();
119 size_t pendingBufferSize();
121 void signalClientClose();
122 void signalRequestError();
123 size_t readBuffer(byte* buffer,
size_t length);
124 size_t getCacheSize();
125 bool checkWebsocket();
128 char _receiveBuffer[HTTPS_CONNECTION_DATA_CHUNK_SIZE];
131 int _bufferProcessed;
133 int _bufferUnusedIdx;
136 struct sockaddr _sockAddr;
145 std::string text =
"";
146 bool parsingFinished =
false;
150 std::string _httpMethod;
151 std::string _httpResource;
virtual IPAddress getClientIP()
Definition: HTTPConnection.cpp:65
void handleWebsocketHandshake(HTTPRequest *req, HTTPResponse *res)
Definition: HTTPConnection.cpp:652
Represents the request stream for an HTTP request.
Definition: HTTPRequest.hpp:22
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:622
bool isError()
Definition: HTTPConnection.cpp:99
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:18
Represents a single open connection for the plain HTTPServer, without TLS.
Definition: HTTPConnection.hpp:38
bool isClosed()
Definition: HTTPConnection.cpp:92
std::string websocketKeyResponseHash(std::string const &key)
Definition: HTTPConnection.cpp:664
virtual int initialize(int serverSocketID, HTTPHeaders *defaultHeaders)
Definition: HTTPConnection.cpp:33
Definition: ConnectionContext.cpp:3