Stroika Library 3.0d16
 
Loading...
Searching...
No Matches
Stroika::Frameworks::WebServer::Connection Class Reference

A Connection object represents the state (and socket) for an ongoing, active, HTTP Connection, managed by the ConnectionManager class. More...

#include <Connection.h>

Inheritance diagram for Stroika::Frameworks::WebServer::Connection:
Stroika::Foundation::Debug::AssertExternallySynchronizedMutex

Classes

struct  Stats
 

Public Member Functions

nonvirtual ReadAndProcessResult ReadAndProcessMessage () noexcept
 
nonvirtual String ToString (bool abbreviatedOutput=true) const
 

Public Attributes

const Common::ReadOnlyProperty< ConnectionOrientedStreamSocket::Ptrsocket
 
const Common::ReadOnlyProperty< const Request & > request
 
const Common::ReadOnlyProperty< const Response & > response
 
Common::ReadOnlyProperty< Response & > rwResponse
 
const Common::ReadOnlyProperty< Statsstats
 retrieve stats about this connection, like threads used, start/end times. NB: INTERNALLY SYNCRONIZED
 
Common::Property< optional< HTTP::KeepAlive > > remainingConnectionLimits
 

Detailed Description

A Connection object represents the state (and socket) for an ongoing, active, HTTP Connection, managed by the ConnectionManager class.

This tends to get used internally by the ConnectionManager, but you can use it directly. For example:

Example Usage
Connection conn{acceptedSocketConnection,
Connection::Options{.fInterceptorChain = Sequence<Interceptor>{
[=](Message* m) {
Response& response = m->rwResponse ();
response.rwHeaders().server = "stroika-ssdp-server-demo";
response.write (Stroika::Frameworks::UPnP::Serialize (d, dd));
response.contentType = DataExchange::InternetMediaTypes::kXML;
}}}}};
conn.SetRemainingConnectionMessages (Connection::Remaining{0, 0}); // disable keep-alives
conn.ReadAndProcessMessage ();
A generalization of a vector: a container whose elements are keyed by the natural numbers.
Definition Sequence.h:187
A Connection object represents the state (and socket) for an ongoing, active, HTTP Connection,...
const Common::ReadOnlyProperty< const Response & > response
Note
Thread-Safety C++-Standard-Thread-Safety

Definition at line 77 of file Frameworks/WebServer/Connection.h.

Member Function Documentation

◆ ReadAndProcessMessage()

Connection::ReadAndProcessResult Connection::ReadAndProcessMessage ( )
noexcept

Return eTryAgainLater if 'keep alive' (or otherwise should try again - like incomplete input).

Delegate to interceptor chain. This is the principle EXTENSION point for the Stroika Framework webserver. This is where you modify the response somehow or other (typically through routes).

Definition at line 306 of file Frameworks/WebServer/Connection.cpp.

◆ ToString()

String Connection::ToString ( bool  abbreviatedOutput = true) const
See also
Characters::ToString ();

Definition at line 545 of file Frameworks/WebServer/Connection.cpp.

Member Data Documentation

◆ socket

const Common::ReadOnlyProperty<ConnectionOrientedStreamSocket::Ptr> Stroika::Frameworks::WebServer::Connection::socket

This returns the (two way) connection oriented stream socket (ptr) used by this connection.

Definition at line 133 of file Frameworks/WebServer/Connection.h.

◆ request

const Common::ReadOnlyProperty<const Request&> Stroika::Frameworks::WebServer::Connection::request

Access a (read-only) reference of the underlying connection request

Definition at line 139 of file Frameworks/WebServer/Connection.h.

◆ response

const Common::ReadOnlyProperty<const Response&> Stroika::Frameworks::WebServer::Connection::response

Access a (read-only) reference of the underlying connection request

Definition at line 145 of file Frameworks/WebServer/Connection.h.

◆ rwResponse

Common::ReadOnlyProperty<Response&> Stroika::Frameworks::WebServer::Connection::rwResponse

Access a (read-only) reference to the underlying (modifiable) connection response (meaning you cannot assign to the response itself, but you can modify the response object)

Definition at line 151 of file Frameworks/WebServer/Connection.h.

◆ stats

const Common::ReadOnlyProperty<Stats> Stroika::Frameworks::WebServer::Connection::stats

retrieve stats about this connection, like threads used, start/end times. NB: INTERNALLY SYNCRONIZED

\note   \em Thread-Safety   <a href='#Internally-Synchronized-Thread-Safety'>Internally-Synchronized-Thread-Safety</a>

Definition at line 199 of file Frameworks/WebServer/Connection.h.

◆ remainingConnectionLimits

Common::Property<optional<HTTP::KeepAlive> > Stroika::Frameworks::WebServer::Connection::remainingConnectionLimits
Note
set Remaining::fMessages := 0 to prevent keep-alives.
Example Usage
conn.remainingConnectionLimits = KeepAlive{0, 0}; // disable keep-alives

Definition at line 224 of file Frameworks/WebServer/Connection.h.


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