C++ Actor Framework 0.19
Loading...
Searching...
No Matches
Public Member Functions | List of all members
caf::net::http::lower_layer Class Referenceabstract

Parses HTTP requests and passes them to the upper layer. More...

#include <lower_layer.hpp>

Inheritance diagram for caf::net::http::lower_layer:
caf::net::generic_lower_layer caf::net::http::server

Public Member Functions

virtual void request_messages ()=0
 Start or re-start reading data from the client.
 
virtual void suspend_reading ()=0
 Stops reading messages until calling request_messages.
 
virtual void begin_header (status code)=0
 Starts writing an HTTP header.
 
virtual void add_header_field (std::string_view key, std::string_view val)=0
 Adds a header field.
 
virtual bool end_header ()=0
 Seals the header and transports it to the client.
 
virtual bool send_payload (const_byte_span bytes)=0
 Sends the payload after the header.
 
virtual bool send_chunk (const_byte_span bytes)=0
 Sends a chunk of data if the full payload is unknown when starting to send.
 
virtual bool send_end_of_chunks ()=0
 Sends the last chunk, completing a chunked payload.
 
bool send_response (status code)
 Sends a response that only consists of a header with a status code such as status::no_content.
 
bool send_response (status code, std::string_view content_type, const_byte_span content)
 Convenience function for sending header and payload.
 
bool send_response (status code, std::string_view content_type, std::string_view content)
 Sends a response that only consists of a header with a status code such as status::no_content.
 
bool send_response (status code, const error &err)
 Sends a response that only consists of a header with a status code such as status::no_content.
 
virtual void switch_protocol (std::unique_ptr< octet_stream::upper_layer > next)=0
 Asks the stream to swap the HTTP layer with next after returning from consume.
 
- Public Member Functions inherited from caf::net::generic_lower_layer
virtual multiplexermpx () noexcept=0
 Returns the multiplexer instance that executes this protocol stack.
 
virtual bool can_send_more () const noexcept=0
 Queries whether the output device can accept more data straight away.
 
virtual bool is_reading () const noexcept=0
 Queries whether the lower layer is currently reading from its input device.
 
virtual void write_later ()=0
 Triggers a write callback after the write device signals downstream capacity.
 
virtual void shutdown ()=0
 Shuts down any connection or session gracefully.
 
virtual void shutdown (const error &reason)
 Shuts down any connection or session du to an error.
 

Detailed Description

Parses HTTP requests and passes them to the upper layer.

Member Function Documentation

◆ add_header_field()

virtual void caf::net::http::lower_layer::add_header_field ( std::string_view  key,
std::string_view  val 
)
pure virtual

Adds a header field.

Users may only call this function between begin_header and end_header.

Implemented in caf::net::http::server.

◆ begin_header()

virtual void caf::net::http::lower_layer::begin_header ( status  code)
pure virtual

Starts writing an HTTP header.

Implemented in caf::net::http::server.

◆ end_header()

virtual bool caf::net::http::lower_layer::end_header ( )
pure virtual

Seals the header and transports it to the client.

Implemented in caf::net::http::server.

◆ request_messages()

virtual void caf::net::http::lower_layer::request_messages ( )
pure virtual

Start or re-start reading data from the client.

Implemented in caf::net::http::server.

◆ send_chunk()

virtual bool caf::net::http::lower_layer::send_chunk ( const_byte_span  bytes)
pure virtual

Sends a chunk of data if the full payload is unknown when starting to send.

Implemented in caf::net::http::server.

◆ send_end_of_chunks()

virtual bool caf::net::http::lower_layer::send_end_of_chunks ( )
pure virtual

Sends the last chunk, completing a chunked payload.

Implemented in caf::net::http::server.

◆ send_payload()

virtual bool caf::net::http::lower_layer::send_payload ( const_byte_span  bytes)
pure virtual

Sends the payload after the header.

Implemented in caf::net::http::server.

◆ send_response() [1/3]

bool caf::net::http::lower_layer::send_response ( status  code,
const error err 
)

Sends a response that only consists of a header with a status code such as status::no_content.

◆ send_response() [2/3]

bool caf::net::http::lower_layer::send_response ( status  code,
std::string_view  content_type,
const_byte_span  content 
)

Convenience function for sending header and payload.

Automatically sets the header fields Content-Type and Content-Length.

◆ send_response() [3/3]

bool caf::net::http::lower_layer::send_response ( status  code,
std::string_view  content_type,
std::string_view  content 
)

Sends a response that only consists of a header with a status code such as status::no_content.

◆ suspend_reading()

virtual void caf::net::http::lower_layer::suspend_reading ( )
pure virtual

Stops reading messages until calling request_messages.

Implemented in caf::net::http::server.

◆ switch_protocol()

virtual void caf::net::http::lower_layer::switch_protocol ( std::unique_ptr< octet_stream::upper_layer next)
pure virtual

Asks the stream to swap the HTTP layer with next after returning from consume.

Note
may only be called from the upper layer in consume.

Implemented in caf::net::http::server.


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