Sha256: 4d3274d560af3dd2772e39458152d115aa38e89fcf454ea08f696b504d02297a

Contents?: true

Size: 1.88 KB

Versions: 16

Compression:

Stored size: 1.88 KB

Contents

//
// connection.hpp
// ~~~~~~~~~~~~~~
//
// Copyright (c) 2003-2020 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// 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)
//

#ifndef HTTP_SERVER2_CONNECTION_HPP
#define HTTP_SERVER2_CONNECTION_HPP

#include <asio.hpp>
#include <boost/array.hpp>
#include <boost/noncopyable.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/enable_shared_from_this.hpp>
#include "reply.hpp"
#include "request.hpp"
#include "request_handler.hpp"
#include "request_parser.hpp"

namespace http {
namespace server2 {

/// Represents a single connection from a client.
class connection
  : public boost::enable_shared_from_this<connection>,
    private boost::noncopyable
{
public:
  /// Construct a connection with the given io_context.
  explicit connection(asio::io_context& io_context,
      request_handler& handler);

  /// Get the socket associated with the connection.
  asio::ip::tcp::socket& socket();

  /// Start the first asynchronous operation for the connection.
  void start();

private:
  /// Handle completion of a read operation.
  void handle_read(const asio::error_code& e,
      std::size_t bytes_transferred);

  /// Handle completion of a write operation.
  void handle_write(const asio::error_code& e);

  /// Socket for the connection.
  asio::ip::tcp::socket socket_;

  /// The handler used to process the incoming request.
  request_handler& request_handler_;

  /// Buffer for incoming data.
  boost::array<char, 8192> buffer_;

  /// The incoming request.
  request request_;

  /// The parser for the incoming request.
  request_parser request_parser_;

  /// The reply to be sent back to the client.
  reply reply_;
};

typedef boost::shared_ptr<connection> connection_ptr;

} // namespace server2
} // namespace http

#endif // HTTP_SERVER2_CONNECTION_HPP

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
couchbase-3.0.0.alpha.4-x86_64-linux ext/third_party/asio/asio/src/examples/cpp03/http/server2/connection.hpp
couchbase-3.0.0.alpha.4-x86_64-darwin-19 ext/third_party/asio/asio/src/examples/cpp03/http/server2/connection.hpp
couchbase-3.0.0.alpha.4-universal-darwin-19 ext/third_party/asio/asio/src/examples/cpp03/http/server2/connection.hpp
couchbase-3.0.0.alpha.4 ext/third_party/asio/asio/src/examples/cpp03/http/server2/connection.hpp
couchbase-3.0.0.alpha.3-x86_64-linux ext/third_party/asio/asio/src/examples/cpp03/http/server2/connection.hpp
couchbase-3.0.0.alpha.3-x86_64-darwin-19 ext/third_party/asio/asio/src/examples/cpp03/http/server2/connection.hpp
couchbase-3.0.0.alpha.3-universal-darwin-19 ext/third_party/asio/asio/src/examples/cpp03/http/server2/connection.hpp
couchbase-3.0.0.alpha.3 ext/third_party/asio/asio/src/examples/cpp03/http/server2/connection.hpp
couchbase-3.0.0.alpha.2-x86_64-linux ext/third_party/asio/asio/src/examples/cpp03/http/server2/connection.hpp
couchbase-3.0.0.alpha.2-x86_64-darwin-19 ext/third_party/asio/asio/src/examples/cpp03/http/server2/connection.hpp
couchbase-3.0.0.alpha.2-universal-darwin-19 ext/third_party/asio/asio/src/examples/cpp03/http/server2/connection.hpp
couchbase-3.0.0.alpha.2 ext/third_party/asio/asio/src/examples/cpp03/http/server2/connection.hpp
couchbase-3.0.0.alpha.1-x86_64-linux ext/third_party/asio/asio/src/examples/cpp03/http/server2/connection.hpp
couchbase-3.0.0.alpha.1-x86_64-darwin-19 ext/third_party/asio/asio/src/examples/cpp03/http/server2/connection.hpp
couchbase-3.0.0.alpha.1-universal-darwin-19 ext/third_party/asio/asio/src/examples/cpp03/http/server2/connection.hpp
couchbase-3.0.0.alpha.1 ext/third_party/asio/asio/src/examples/cpp03/http/server2/connection.hpp