AsyncFw 1.2
Async Framework is c++ runtime with timers, poll notifiers, sockets, coroutines, etc.
 
Loading...
Searching...
No Matches
HttpSocket.h
1/*
2Copyright (c) 2026 Alexandr Kuzmuk
3
4This file is part of the AsyncFw project. Licensed under the MIT License.
5See {Link: LICENSE file https://mit-license.org} in the project root for full license information.
6*/
7
8#pragma once
9
10#include "../core/FunctionConnector.h"
11#include "../core/DataArray.h"
12#include "../core/AbstractTlsSocket.h"
13#include "File.h"
14
15namespace AsyncFw {
18class HttpSocket : public AsyncFw::AbstractTlsSocket {
19 friend LogStream &operator<<(LogStream &, const HttpSocket &);
20
21public:
22 static HttpSocket *create(AsyncFw::Thread *_t = nullptr);
23
24 void stateEvent() override;
25 void activateEvent() override;
26 void readEvent() override;
27 void writeEvent() override;
28
29 void disconnect() override;
30 void close() override;
31 void destroy() override;
32
34 AsyncFw::DataArrayView content();
35 void sendFile(const std::string &);
36
37 AsyncFw::FunctionConnectorProtected<HttpSocket>::Connector<const AsyncFw::AbstractSocket::State> stateChanged;
38 AsyncFw::FunctionConnectorProtected<HttpSocket>::Connector<const AsyncFw::DataArray &> received;
39 AsyncFw::FunctionConnectorProtected<HttpSocket>::Connector<> writeContent;
40 AsyncFw::FunctionConnectorProtected<HttpSocket>::Connector<int> progress;
41
42protected:
43 HttpSocket();
44 ~HttpSocket();
45 void clearReceived();
46 bool connectionClose = false;
47
48private:
49 AsyncFw::DataArray received_;
50 AsyncFw::File file_;
51 int progress_;
52 int headerSize_;
53 std::size_t contentLenght_ = std::string::npos;
54 int tid_ = -1;
55 bool full_ = false;
56};
57} // namespace AsyncFw
The AbstractTlsSocket class provides the base functionality for TLS encrypted socket.
Definition AbstractTlsSocket.h:17
The DataArrayView class.
Definition DataArray.h:37
The DataArray class.
Definition DataArray.h:20
The File class.
Definition File.h:16
The LogStream class.
Definition LogStream.h:44
AsyncFw::Thread thread with sockets.
Definition Thread.h:16