File: connection.hpp

package info (click to toggle)
libzeep 7.3.2-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,372 kB
  • sloc: cpp: 17,430; javascript: 180; makefile: 12; sh: 11
file content (49 lines) | stat: -rw-r--r-- 1,377 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
//        Copyright Maarten L. Hekkelman, 2014-2026
// Copyright Maarten L. Hekkelman, Radboud University 2008-2013.
//  Distributed under the Boost Software License, Version 1.0.
//     (See accompanying file LICENSE_1_0.txt or copy at
//           http://www.boost.org/LICENSE_1_0.txt)

#pragma once

/// \file
/// definition of the zeep::http::connection class, that handles HTTP connections

#include "zeep/http/message-parser.hpp"

#include <memory>

namespace zeep::http
{

class basic_server;

/// The HTTP server implementation of libzeep is inspired by the example code
/// as provided by boost::asio. These objects are not to be used directly.

class connection
	: public std::enable_shared_from_this<connection>
{
  public:
	connection(connection &) = delete;
	connection &operator=(connection &) = delete;

	connection(asio_ns::io_context &service, basic_server &handler);

	void start();
	void handle_read(asio_system_ns::error_code ec, size_t bytes_transferred);
	void handle_write(asio_system_ns::error_code ec, size_t bytes_transferred);

	asio_ns::ip::tcp::socket &get_socket() { return m_socket; }

  private:
	asio_ns::ip::tcp::socket m_socket;
	basic_server &m_server;
	reply m_reply;
	request_parser m_request_parser;
	bool m_keep_alive = false;
	asio_ns::streambuf m_buffer;
	asio_ns::streambuf::mutable_buffers_type m_bufs;
};

} // namespace zeep::http