4#include "../AsyncStreams/AsyncStreams.h"
5#include "../Foundation/Function.h"
6#include "../Foundation/Result.h"
7#include "../Foundation/Span.h"
14struct HttpAsyncClient;
15struct HttpAsyncClientRequest;
16struct HttpAsyncClientResponse;
51 uint8_t maskKey[4] = {0, 0, 0, 0};
53 [[nodiscard]]
bool isControlFrame()
const;
65 [[nodiscard]]
bool isValid()
const
67 return readableStream !=
nullptr and writableStream !=
nullptr and buffersPool !=
nullptr;
103 Status status = Status::BadRequest;
105 [[nodiscard]]
bool accepted()
const {
return status == Status::Accepted; }
106 [[nodiscard]]
int httpStatusCode()
const;
112 static constexpr size_t ClientKeyLength = 24;
113 static constexpr size_t AcceptKeyLength = 28;
114 static constexpr size_t NonceLength = 16;
150 void onClientError(
Result result);
178 Result finishCurrentFrame();
183 State state = State::HeaderByte0;
185 bool fragmentedMessageInProgress =
false;
189 uint8_t extendedLengthBytesExpected = 0;
190 uint8_t extendedLengthBytesRead = 0;
193 uint64_t extendedLengthAccumulator = 0;
211 bool frameInProgress =
false;
212 bool fragmentedMessageInProgress =
false;
228 [[nodiscard]]
size_t getCurrentMessageSize()
const {
return messageSize; }
236 size_t messageSize = 0;
238 bool assemblingMessage =
false;
239 bool ignoringFrame =
false;
252 void setAutomaticMaskKey(
const uint8_t maskKey[4]);
267 [[nodiscard]]
bool hasPendingControlFrame()
const {
return pendingControlFrame.sizeInBytes() > 0; }
269 void clearPendingControlFrame();
271 [[nodiscard]]
bool hasCloseBeenSent()
const {
return closeSent; }
272 [[nodiscard]]
bool hasCloseBeenReceived()
const {
return closeReceived; }
286 char controlPayload[125] = {0};
287 size_t controlPayloadSize = 0;
288 char automaticControlStorage[2 + 8 + 4 + 125] = {0};
290 uint8_t automaticMaskKey[4] = {0, 0, 0, 0};
292 bool automaticMaskKeySet =
false;
293 bool closeSent =
false;
294 bool closeReceived =
false;
308 Result flushPendingControlFrame();
310 [[nodiscard]]
bool isAttached()
const {
return transport.isValid(); }
325 bool dataListenerAdded =
false;
326 bool endListenerAdded =
false;
327 bool closeListenerAdded =
false;
347 Result leave(
size_t clientIndex);
352 [[nodiscard]]
size_t getNumClients()
const {
return numClients; }
353 [[nodiscard]]
size_t getCapacity()
const {
return clients.sizeInElements(); }
354 [[nodiscard]]
bool isClientActive(
size_t clientIndex)
const;
358 size_t numClients = 0;
unsigned short uint16_t
Platform independent (2) bytes unsigned int.
Definition PrimitiveTypes.h:28
struct SC_FOUNDATION_EXPORT Function
Wraps function pointers, member functions and lambdas without ever allocating.
Definition Function.h:19
unsigned char uint8_t
Platform independent (1) byte unsigned int.
Definition PrimitiveTypes.h:27
unsigned long long uint64_t
Platform independent (8) bytes unsigned int.
Definition PrimitiveTypes.h:33
unsigned int uint32_t
Platform independent (4) bytes unsigned int.
Definition PrimitiveTypes.h:29
HttpWebSocketEndpointRole
Identifies the local endpoint role to validate masking rules.
Definition HttpWebSocket.h:38
HttpWebSocketOpcode
WebSocket frame opcode as defined by RFC 6455.
Definition HttpWebSocket.h:26
Definition AsyncStreams.h:58
Holds a Span of AsyncBufferView (allocated by user) holding available memory for the streams.
Definition AsyncStreams.h:169
Asynchronous I/O (files, sockets, timers, processes, fs events, threads wake-up) (see Async) AsyncEve...
Definition Async.h:1397
Async source abstraction emitting data events in caller provided byte buffers.
Definition AsyncStreams.h:220
Async destination abstraction where bytes can be written to.
Definition AsyncStreams.h:356
Outgoing HTTP request sent by the client.
Definition HttpConnection.h:405
Incoming HTTP response received by the client.
Definition HttpConnection.h:246
Asynchronous HTTP/1.1 client using caller-provided fixed storage.
Definition HttpAsyncClient.h:49
Http connection abstraction holding both the incoming and outgoing messages in an HTTP transaction.
Definition HttpConnection.h:467
Method
Method of the current request / response.
Definition HttpParser.h:19
Incoming HTTP request received by the server.
Definition HttpConnection.h:220
Outgoing HTTP response sent by the server.
Definition HttpConnection.h:370
Normalized client-side WebSocket opening handshake response data.
Definition HttpWebSocket.h:85
Small client-side helper that upgrades an HttpAsyncClient connection to a WebSocket transport.
Definition HttpWebSocket.h:140
Optional stream pump that binds a WebSocket transport to an endpoint lifecycle.
Definition HttpWebSocket.h:299
Small frame-lifecycle helper for ping / pong, close, and explicit fixed-buffer send backpressure.
Definition HttpWebSocket.h:244
Incremental WebSocket frame reader operating on caller-owned mutable byte slices.
Definition HttpWebSocket.h:160
Incremental WebSocket frame writer operating on caller-owned header storage and payload buffers.
Definition HttpWebSocket.h:200
Outcome of validating a WebSocket opening handshake.
Definition HttpWebSocket.h:95
Dependency-free RFC 6455 opening handshake helpers.
Definition HttpWebSocket.h:111
Fixed-slot WebSocket hub client entry.
Definition HttpWebSocket.h:332
Optional caller-buffered message assembly helper for applications that want complete messages.
Definition HttpWebSocket.h:220
Normalized server-side WebSocket opening handshake data.
Definition HttpWebSocket.h:73
Small fixed-capacity broadcast helper for server-side WebSocket fan-out.
Definition HttpWebSocket.h:341
Minimal transport handoff shape for later HTTP upgrade integration.
Definition HttpWebSocket.h:58
An ascii string used as boolean result. SC_TRY macro forwards errors to caller.
Definition Result.h:13
View over a contiguous sequence of items (pointer + size in elements).
Definition Span.h:29
An read-only view over a string (to avoid including Strings library when parsing is not needed).
Definition StringSpan.h:37