Sane C++ Libraries
C++ Platform Abstraction Libraries
Loading...
Searching...
No Matches
SC::HttpIncomingMessage Struct Reference

Incoming message from the perspective of the participants of an HTTP transaction. More...

#include <HttpConnection.h>

Inheritance diagram for SC::HttpIncomingMessage:
SC::HttpAsyncClientResponse SC::HttpRequest

Public Member Functions

const HttpParsergetParser () const
 Gets the associated HttpParser.
 
bool getKeepAlive () const
 Gets whether the other party requested the connection to stay alive.
 
uint64_t getBodyBytesRemaining () const
 Returns how many body bytes are still expected for this message.
 
bool isMultipart () const
 Checks if the request is a multipart/form-data request.
 
StringSpan getBoundary () const
 Gets the multipart boundary string (if isMultipart() returns true)
 
bool getHeader (StringSpan headerName, StringSpan &value) const
 Gets the value of a specific header (case-insensitive name matching)
 
AsyncReadableStreamgetReadableStream ()
 Obtains the readable stream for the message body.
 
const AsyncReadableStreamgetReadableStream () const
 Obtains the readable stream for the message body.
 
Result consumeBodyBytes (size_t bytes)
 Decrements the remaining body bytes after consuming data.
 

Protected Member Functions

void resetIncoming (HttpParser::Type type, Span< char > memory)
 
bool hasReceivedHeaders () const
 
Span< char > getUnusedHeaderMemory () const
 
void attachReadableStream (AsyncReadableStream &stream)
 
void setBodyBytesRemaining (uint64_t value)
 
bool findParserToken (HttpParser::Token token, StringSpan &res) const
 Finds a specific HttpParser::Result in the list of parsed header.
 
Result writeHeaders (const uint32_t maxHeaderSize, Span< const char > readData, AsyncReadableStream &stream, AsyncBufferView::ID bufferID, const char *outOfSpaceError, const char *sizeExceededError, bool stopAtHeadersEnd)
 Parses an incoming slice of data eventually copying it to the availableHeader.
 
size_t getHeadersLength () const
 Gets the length of the headers in bytes.
 

Protected Attributes

HttpParsedHeaders parsedHeaders
 
Span< char > headerMemory
 
AsyncReadableStreamreadableStream = nullptr
 
uint64_t bodyBytesRemaining = 0
 

Detailed Description

Incoming message from the perspective of the participants of an HTTP transaction.

Member Function Documentation

◆ consumeBodyBytes()

Result SC::HttpIncomingMessage::consumeBodyBytes ( size_t bytes)

Decrements the remaining body bytes after consuming data.

◆ findParserToken()

bool SC::HttpIncomingMessage::findParserToken ( HttpParser::Token token,
StringSpan & res ) const
nodiscardprotected

Finds a specific HttpParser::Result in the list of parsed header.

Parameters
tokenThe result to look for (Method, Url etc.)
resA StringSpan, pointing at headerBuffer containing the found result
Returns
true if the result has been found

◆ getBodyBytesRemaining()

uint64_t SC::HttpIncomingMessage::getBodyBytesRemaining ( ) const
inlinenodiscard

Returns how many body bytes are still expected for this message.

◆ getBoundary()

StringSpan SC::HttpIncomingMessage::getBoundary ( ) const
nodiscard

Gets the multipart boundary string (if isMultipart() returns true)

◆ getHeader()

bool SC::HttpIncomingMessage::getHeader ( StringSpan headerName,
StringSpan & value ) const
nodiscard

Gets the value of a specific header (case-insensitive name matching)

Parameters
headerNameThe name of the header to find
valueOutput parameter that receives the header value if found
Returns
true if the header was found

◆ getHeadersLength()

size_t SC::HttpIncomingMessage::getHeadersLength ( ) const
nodiscardprotected

Gets the length of the headers in bytes.

◆ getKeepAlive()

bool SC::HttpIncomingMessage::getKeepAlive ( ) const
inlinenodiscard

Gets whether the other party requested the connection to stay alive.

◆ getParser()

const HttpParser & SC::HttpIncomingMessage::getParser ( ) const
inline

Gets the associated HttpParser.

◆ getReadableStream() [1/2]

AsyncReadableStream & SC::HttpIncomingMessage::getReadableStream ( )

Obtains the readable stream for the message body.

◆ getReadableStream() [2/2]

const AsyncReadableStream & SC::HttpIncomingMessage::getReadableStream ( ) const

Obtains the readable stream for the message body.

◆ isMultipart()

bool SC::HttpIncomingMessage::isMultipart ( ) const
nodiscard

Checks if the request is a multipart/form-data request.

◆ writeHeaders()

Result SC::HttpIncomingMessage::writeHeaders ( const uint32_t maxHeaderSize,
Span< const char > readData,
AsyncReadableStream & stream,
AsyncBufferView::ID bufferID,
const char * outOfSpaceError,
const char * sizeExceededError,
bool stopAtHeadersEnd )
protected

Parses an incoming slice of data eventually copying it to the availableHeader.

If it encounters body data, it will create a child view and unshift it to the stream.


The documentation for this struct was generated from the following file: