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,
110 void raiseError(uint16_t code, std::string reason);
111 void readLine(
int lengthLimit);
113 bool isTimeoutExceeded();
114 void refreshTimeout();
117 size_t pendingBufferSize();
119 void signalClientClose();
120 void signalRequestError();
121 size_t readBuffer(byte* buffer,
size_t length);
122 size_t getCacheSize();
123 bool checkWebsocket();
126 char _receiveBuffer[HTTPS_CONNECTION_DATA_CHUNK_SIZE];
129 int _bufferProcessed;
131 int _bufferUnusedIdx;
134 struct sockaddr _sockAddr;
143 std::string text =
"";
144 bool parsingFinished =
false;
148 std::string _httpMethod;
149 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