Crow  1.0
A C++ microframework for the web
crow::Connection< Adaptor, Handler, Middlewares > Class Template Reference

An HTTP connection. More...

Collaboration diagram for crow::Connection< Adaptor, Handler, Middlewares >:

Public Member Functions

 Connection (boost::asio::io_service &io_service, Handler *handler, const std::string &server_name, std::tuple< Middlewares... > *middlewares, std::function< std::string()> &get_cached_date_str_f, detail::task_timer &task_timer, typename Adaptor::context *adaptor_ctx_, std::atomic< unsigned int > &queue_length)
 
 ~Connection ()
 
decltype(std::declval< Adaptor >().raw_socket()) & socket ()
 The TCP socket on top of which the connection is established. More...
 
void start ()
 
void handle_header ()
 
void handle ()
 
void complete_request ()
 Call the after handle middleware and send the write the response to the connection. More...
 

Private Member Functions

void prepare_buffers ()
 
void do_write_static ()
 
void do_write_general ()
 
void do_read ()
 
void do_write ()
 
void do_write_sync (std::vector< asio::const_buffer > &buffers)
 
void check_destroy ()
 
void cancel_deadline_timer ()
 
void start_deadline ()
 

Private Attributes

Adaptor adaptor_
 
Handler * handler_
 
boost::array< char, 4096 > buffer_
 
HTTPParser< Connectionparser_
 
request req_
 
response res
 
bool close_connection_ = false
 
const std::string & server_name_
 
std::vector< boost::asio::const_buffer > buffers_
 
std::string content_length_
 
std::string date_str_
 
std::string res_body_copy_
 
detail::task_timer::identifier_type task_id_
 
bool is_reading {}
 
bool is_writing {}
 
bool need_to_call_after_handlers_ {}
 
bool need_to_start_read_after_complete_ {}
 
bool add_keep_alive_ {}
 
std::tuple< Middlewares... > * middlewares_
 
detail::context< Middlewares... > ctx_
 
std::function< std::string()> & get_cached_date_str
 
detail::task_timertask_timer_
 
size_t res_stream_threshold_
 
std::atomic< unsigned int > & queue_length_
 

Friends

struct crow::response
 

Detailed Description

template<typename Adaptor, typename Handler, typename... Middlewares>
class crow::Connection< Adaptor, Handler, Middlewares >

An HTTP connection.

Constructor & Destructor Documentation

◆ Connection()

template<typename Adaptor , typename Handler , typename... Middlewares>
crow::Connection< Adaptor, Handler, Middlewares >::Connection ( boost::asio::io_service &  io_service,
Handler *  handler,
const std::string &  server_name,
std::tuple< Middlewares... > *  middlewares,
std::function< std::string()> &  get_cached_date_str_f,
detail::task_timer task_timer,
typename Adaptor::context *  adaptor_ctx_,
std::atomic< unsigned int > &  queue_length 
)
inline

◆ ~Connection()

template<typename Adaptor , typename Handler , typename... Middlewares>
crow::Connection< Adaptor, Handler, Middlewares >::~Connection ( )
inline

Member Function Documentation

◆ socket()

template<typename Adaptor , typename Handler , typename... Middlewares>
decltype(std::declval<Adaptor>().raw_socket()) & crow::Connection< Adaptor, Handler, Middlewares >::socket ( )
inline

The TCP socket on top of which the connection is established.

◆ start()

template<typename Adaptor , typename Handler , typename... Middlewares>
void crow::Connection< Adaptor, Handler, Middlewares >::start ( )
inline

◆ handle_header()

template<typename Adaptor , typename Handler , typename... Middlewares>
void crow::Connection< Adaptor, Handler, Middlewares >::handle_header ( )
inline
Here is the call graph for this function:

◆ handle()

template<typename Adaptor , typename Handler , typename... Middlewares>
void crow::Connection< Adaptor, Handler, Middlewares >::handle ( )
inline
Here is the call graph for this function:

◆ complete_request()

template<typename Adaptor , typename Handler , typename... Middlewares>
void crow::Connection< Adaptor, Handler, Middlewares >::complete_request ( )
inline

Call the after handle middleware and send the write the response to the connection.

Here is the call graph for this function:

◆ prepare_buffers()

template<typename Adaptor , typename Handler , typename... Middlewares>
void crow::Connection< Adaptor, Handler, Middlewares >::prepare_buffers ( )
inlineprivate
Here is the call graph for this function:

◆ do_write_static()

template<typename Adaptor , typename Handler , typename... Middlewares>
void crow::Connection< Adaptor, Handler, Middlewares >::do_write_static ( )
inlineprivate

◆ do_write_general()

template<typename Adaptor , typename Handler , typename... Middlewares>
void crow::Connection< Adaptor, Handler, Middlewares >::do_write_general ( )
inlineprivate

◆ do_read()

template<typename Adaptor , typename Handler , typename... Middlewares>
void crow::Connection< Adaptor, Handler, Middlewares >::do_read ( )
inlineprivate

◆ do_write()

template<typename Adaptor , typename Handler , typename... Middlewares>
void crow::Connection< Adaptor, Handler, Middlewares >::do_write ( )
inlineprivate

◆ do_write_sync()

template<typename Adaptor , typename Handler , typename... Middlewares>
void crow::Connection< Adaptor, Handler, Middlewares >::do_write_sync ( std::vector< asio::const_buffer > &  buffers)
inlineprivate

◆ check_destroy()

template<typename Adaptor , typename Handler , typename... Middlewares>
void crow::Connection< Adaptor, Handler, Middlewares >::check_destroy ( )
inlineprivate

◆ cancel_deadline_timer()

template<typename Adaptor , typename Handler , typename... Middlewares>
void crow::Connection< Adaptor, Handler, Middlewares >::cancel_deadline_timer ( )
inlineprivate

◆ start_deadline()

template<typename Adaptor , typename Handler , typename... Middlewares>
void crow::Connection< Adaptor, Handler, Middlewares >::start_deadline ( )
inlineprivate

Friends And Related Function Documentation

◆ crow::response

template<typename Adaptor , typename Handler , typename... Middlewares>
friend struct crow::response
friend

Member Data Documentation

◆ adaptor_

template<typename Adaptor , typename Handler , typename... Middlewares>
Adaptor crow::Connection< Adaptor, Handler, Middlewares >::adaptor_
private

◆ handler_

template<typename Adaptor , typename Handler , typename... Middlewares>
Handler* crow::Connection< Adaptor, Handler, Middlewares >::handler_
private

◆ buffer_

template<typename Adaptor , typename Handler , typename... Middlewares>
boost::array<char, 4096> crow::Connection< Adaptor, Handler, Middlewares >::buffer_
private

◆ parser_

template<typename Adaptor , typename Handler , typename... Middlewares>
HTTPParser<Connection> crow::Connection< Adaptor, Handler, Middlewares >::parser_
private

◆ req_

template<typename Adaptor , typename Handler , typename... Middlewares>
request crow::Connection< Adaptor, Handler, Middlewares >::req_
private

◆ res

template<typename Adaptor , typename Handler , typename... Middlewares>
response crow::Connection< Adaptor, Handler, Middlewares >::res
private

◆ close_connection_

template<typename Adaptor , typename Handler , typename... Middlewares>
bool crow::Connection< Adaptor, Handler, Middlewares >::close_connection_ = false
private

◆ server_name_

template<typename Adaptor , typename Handler , typename... Middlewares>
const std::string& crow::Connection< Adaptor, Handler, Middlewares >::server_name_
private

◆ buffers_

template<typename Adaptor , typename Handler , typename... Middlewares>
std::vector<boost::asio::const_buffer> crow::Connection< Adaptor, Handler, Middlewares >::buffers_
private

◆ content_length_

template<typename Adaptor , typename Handler , typename... Middlewares>
std::string crow::Connection< Adaptor, Handler, Middlewares >::content_length_
private

◆ date_str_

template<typename Adaptor , typename Handler , typename... Middlewares>
std::string crow::Connection< Adaptor, Handler, Middlewares >::date_str_
private

◆ res_body_copy_

template<typename Adaptor , typename Handler , typename... Middlewares>
std::string crow::Connection< Adaptor, Handler, Middlewares >::res_body_copy_
private

◆ task_id_

template<typename Adaptor , typename Handler , typename... Middlewares>
detail::task_timer::identifier_type crow::Connection< Adaptor, Handler, Middlewares >::task_id_
private

◆ is_reading

template<typename Adaptor , typename Handler , typename... Middlewares>
bool crow::Connection< Adaptor, Handler, Middlewares >::is_reading {}
private

◆ is_writing

template<typename Adaptor , typename Handler , typename... Middlewares>
bool crow::Connection< Adaptor, Handler, Middlewares >::is_writing {}
private

◆ need_to_call_after_handlers_

template<typename Adaptor , typename Handler , typename... Middlewares>
bool crow::Connection< Adaptor, Handler, Middlewares >::need_to_call_after_handlers_ {}
private

◆ need_to_start_read_after_complete_

template<typename Adaptor , typename Handler , typename... Middlewares>
bool crow::Connection< Adaptor, Handler, Middlewares >::need_to_start_read_after_complete_ {}
private

◆ add_keep_alive_

template<typename Adaptor , typename Handler , typename... Middlewares>
bool crow::Connection< Adaptor, Handler, Middlewares >::add_keep_alive_ {}
private

◆ middlewares_

template<typename Adaptor , typename Handler , typename... Middlewares>
std::tuple<Middlewares...>* crow::Connection< Adaptor, Handler, Middlewares >::middlewares_
private

◆ ctx_

template<typename Adaptor , typename Handler , typename... Middlewares>
detail::context<Middlewares...> crow::Connection< Adaptor, Handler, Middlewares >::ctx_
private

◆ get_cached_date_str

template<typename Adaptor , typename Handler , typename... Middlewares>
std::function<std::string()>& crow::Connection< Adaptor, Handler, Middlewares >::get_cached_date_str
private

◆ task_timer_

template<typename Adaptor , typename Handler , typename... Middlewares>
detail::task_timer& crow::Connection< Adaptor, Handler, Middlewares >::task_timer_
private

◆ res_stream_threshold_

template<typename Adaptor , typename Handler , typename... Middlewares>
size_t crow::Connection< Adaptor, Handler, Middlewares >::res_stream_threshold_
private

◆ queue_length_

template<typename Adaptor , typename Handler , typename... Middlewares>
std::atomic<unsigned int>& crow::Connection< Adaptor, Handler, Middlewares >::queue_length_
private

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