fwoop http

class HttpDataFrame : public fwoop::HttpFrame

Public Types

enum Flag

Values:

enumerator EndStream
enumerator Padded

Public Functions

HttpDataFrame(unsigned int length, uint8_t flags, uint8_t *streamID, uint8_t *payload)
explicit HttpDataFrame()
inline ~HttpDataFrame()
virtual uint8_t *encode() const override
inline void addFlag(Flag flag)
void setData(uint8_t *data, uint32_t dataLen)
class HttpFrame

Subclassed by fwoop::HttpDataFrame, fwoop::HttpGoAwayFrame, fwoop::HttpHeadersFrame, fwoop::HttpSettingsFrame, fwoop::HttpWindowUpdateFrame

Public Types

enum class Type

Values:

enumerator Unknown
enumerator Data
enumerator Header
enumerator Priority
enumerator ResetStream
enumerator Settings
enumerator PushPromise
enumerator Ping
enumerator GoAway
enumerator WindowUpdate
enumerator Continuation

Public Functions

HttpFrame(unsigned int length, Type type, uint8_t flags, uint8_t *streamID, uint8_t *payload)
inline virtual ~HttpFrame()
inline void setStreamID(uint32_t id)
inline void setLength(unsigned int length)
inline unsigned int length() const
inline Type type() const
inline uint8_t *payload() const
void printHex() const
void printHeader() const
inline unsigned int encodingLength() const
inline virtual uint8_t *encode() const
inline uint32_t getStreamID() const

Public Static Functions

static std::unique_ptr<HttpFrame> parse(uint8_t *buffer, unsigned int bufferSize, unsigned int &bytesParsed)
static Type byteToType(uint8_t byte)
static std::string typeToString(Type type)

Public Static Attributes

static constexpr unsigned int HEADER_LENGTH = 9
class HttpGoAwayFrame : public fwoop::HttpFrame

Public Functions

HttpGoAwayFrame(unsigned int length, uint8_t flags, uint8_t *streamID, uint8_t *payload)
explicit HttpGoAwayFrame()
inline ~HttpGoAwayFrame()
virtual uint8_t *encode() const override
inline void setLastStreamID(uint32_t streamID)
inline void setErrorCode(uint32_t ec)
enum fwoop::HttpHeader

Values:

enumerator Undefined
enumerator Authority
enumerator Method
enumerator Path
enumerator Scheme
enumerator Status
enumerator AcceptCharset
enumerator AcceptEncoding
enumerator AcceptLanguage
enumerator AcceptRanges
enumerator Accept
enumerator AccessControlAllowOrigin
enumerator Age
enumerator Allow
enumerator Authorization
enumerator CacheControl
enumerator ContentDisposition
enumerator ContentEncoding
enumerator ContentLanguage
enumerator ContentLength
enumerator ContentLocation
enumerator ContentRange
enumerator ContentType
enumerator Cookie
enumerator Date
enumerator Etag
enumerator Expect
enumerator Expires
enumerator From
enumerator Host
enumerator IfMatch
enumerator IfModifiedSince
enumerator IfNoneMatch
enumerator IfRange
enumerator IfUnmodifiedSince
enumerator LastModified
enumerator Link
enumerator Location
enumerator MaxForwards
enumerator ProxyAuthenticate
enumerator ProxyAuthorization
enumerator Range
enumerator Referer
enumerator Refresh
enumerator RetryAfter
enumerator Server
enumerator SetCookie
enumerator StrictTransportSecurity
enumerator TransferEncoding
enumerator UserAgent
enumerator Vary
enumerator Via
enumerator WwwAuthenticate
class HttpHeadersFrame : public fwoop::HttpFrame

Public Types

enum Flag

Values:

enumerator EndStream
enumerator EndHeaders
enumerator Padded
enumerator Priority

Public Functions

HttpHeadersFrame(unsigned int length, uint8_t flags, uint8_t *streamID, uint8_t *payload)
inline explicit HttpHeadersFrame(const std::shared_ptr<HttpHPacker> &packer)
inline void addFlag(Flag flag)
void addHeaderBlock(HttpHeader &&name, std::string &&value)
void addHeaderBlock(const std::string &name, const std::string &value)
inline void clearHeaderBlocks()
virtual uint8_t *encode() const override
inline std::vector<HttpHeaderField_t>::const_iterator beginHeaderList() const
inline std::vector<HttpHeaderField_t>::const_iterator endHeaderList() const
class HttpHPacker

Public Functions

HttpHPacker()
uint32_t getEncodedLength(const std::vector<HttpHeaderField_t> &headerFields) const
uint32_t encodeLength(const std::vector<HttpHeaderField_t> &headerFields)
uint8_t *encode(const std::vector<HttpHeaderField_t> &headerFields)
class HttpRequest

Public Types

enum class Method

Values:

enumerator Undefined
enumerator Get
enumerator Post
enumerator Put
enumerator Delete

Public Functions

explicit HttpRequest()
inline void addHeader(const HttpHeader &name, const std::string &value)
inline void addHeader(const HttpCustomHeader &name, const std::string &value)
inline void setPath(const std::string &path)
inline void setBody(const std::string &body)
inline void setMethod(const Method &method)
inline void setVersion(const HttpVersion::Value &version)
inline Method getMethod() const
inline const std::string &getPath() const
inline HttpVersion::Value getVersion() const
inline const std::vector<HttpHeaderField_t> &getHeaders() const
inline bool canUpgrade() const
uint8_t *encode(uint32_t &length) const

Public Static Functions

static std::shared_ptr<HttpRequest> parse(uint8_t *buffer, uint32_t bufferSize, uint32_t &bytesParsed)
static std::string methodToString(const Method &method)
class HttpResponse

Public Types

enum BuildResult

Values:

enumerator Done
enumerator Incomplete
enumerator Failure

Public Functions

explicit HttpResponse()
BuildResult build(uint8_t *buffer, uint32_t bufferSize, uint32_t &bytesParsed)
inline void setStatus(const std::string &status)
inline void addHeader(const HttpHeader &name, const std::string &value)
inline void addHeader(const HttpCustomHeader &name, const std::string &value)
inline void setBody(const std::string &body)
void streamFile(const std::string &fileName)
uint8_t *encode(uint32_t &length) const
inline const HttpVersion::Value getVersion() const
inline const std::vector<HttpHeaderField_t> getHeaders() const
inline const std::string &getStatus() const
inline const std::string &getBody() const
inline const std::string &getFile() const
class HttpServer : public fwoop::HttpRequestCallback

Public Functions

explicit HttpServer(int port, HttpVersion::Value version, unsigned int threadPoolSize = 5)
~HttpServer()
int serve()
inline void stop()
void addRoute(const std::string &route, HttpHandlerFunc_t func)
void addStaticRoute(const std::string &route, const std::string &fileName)
void addServerEventRoute(const std::string &route, HttpServerEventHandlerFunc_t func)
virtual void onRequest(const std::shared_ptr<HttpRequest> &request, HttpResponse &response) override
virtual void afterResponse(const std::shared_ptr<HttpRequest> &request, WriterPtr_t writer) override
class HttpSettingsFrame : public fwoop::HttpFrame

Public Functions

HttpSettingsFrame(unsigned int length, uint8_t flags, uint8_t *streamID, uint8_t *payload)
explicit HttpSettingsFrame()
inline ~HttpSettingsFrame()
inline void setAck()
inline void setHeaderTableSize(uint32_t headerTableSize)
void setEnablePush(bool enablePush)
void setMaxConcurrentStreams(uint32_t maxConcurrentStreams)
void setInitialWindowSize(uint32_t initialWindowSize)
inline void setMaxFrameSize(uint32_t maxFrameSize)
void setMaxHeaderListSize(uint32_t maxHeaderListSize)
inline std::optional<uint32_t> headerTableSize() const
inline bool enablePush() const
inline std::optional<uint32_t> maxConcurrentStreams() const
inline std::optional<uint32_t> initialWindowSize() const
inline std::optional<uint32_t> maxFrameSize() const
inline std::optional<uint32_t> maxHeaderListSize() const
virtual uint8_t *encode() const override
class HttpStream

Public Functions

explicit HttpStream(int clientFd)
int open()
int close()
class HttpWindowUpdateFrame : public fwoop::HttpFrame

Public Functions

HttpWindowUpdateFrame(unsigned int length, uint8_t flags, uint8_t *streamID, uint8_t *payload)
inline ~HttpWindowUpdateFrame()
virtual uint8_t *encode() const override