Merge request handler to server; add FileBody for serving static files.
This commit is contained in:
+11
-12
@@ -5,7 +5,7 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "boost/asio/ip/tcp.hpp" // for ip::tcp::socket
|
||||
#include "boost/asio/ip/tcp.hpp"
|
||||
|
||||
#include "webcc/globals.h"
|
||||
#include "webcc/request.h"
|
||||
@@ -14,16 +14,13 @@
|
||||
|
||||
namespace webcc {
|
||||
|
||||
class Connection;
|
||||
class ConnectionPool;
|
||||
class RequestHandler;
|
||||
|
||||
using ConnectionPtr = std::shared_ptr<Connection>;
|
||||
class Server;
|
||||
|
||||
class Connection : public std::enable_shared_from_this<Connection> {
|
||||
public:
|
||||
Connection(boost::asio::ip::tcp::socket socket, ConnectionPool* pool,
|
||||
RequestHandler* handler);
|
||||
Server* server);
|
||||
|
||||
~Connection() = default;
|
||||
|
||||
@@ -40,10 +37,10 @@ public:
|
||||
// Close the socket.
|
||||
void Close();
|
||||
|
||||
// Send response to client.
|
||||
// Send a response to the client.
|
||||
void SendResponse(ResponsePtr response);
|
||||
|
||||
// TODO: Remove
|
||||
// Send a response with the given status and an empty body to the client.
|
||||
void SendResponse(Status status);
|
||||
|
||||
private:
|
||||
@@ -60,17 +57,17 @@ private:
|
||||
// Shutdown the socket.
|
||||
void Shutdown();
|
||||
|
||||
// Socket for the connection.
|
||||
// The socket for the connection.
|
||||
boost::asio::ip::tcp::socket socket_;
|
||||
|
||||
// The pool for this connection.
|
||||
ConnectionPool* pool_;
|
||||
|
||||
// Buffer for incoming data.
|
||||
// The buffer for incoming data.
|
||||
std::vector<char> buffer_;
|
||||
|
||||
// The handler used to process the incoming request.
|
||||
RequestHandler* request_handler_;
|
||||
// The server.
|
||||
Server* server_;
|
||||
|
||||
// The incoming request.
|
||||
RequestPtr request_;
|
||||
@@ -82,6 +79,8 @@ private:
|
||||
ResponsePtr response_;
|
||||
};
|
||||
|
||||
using ConnectionPtr = std::shared_ptr<Connection>;
|
||||
|
||||
} // namespace webcc
|
||||
|
||||
#endif // WEBCC_CONNECTION_H_
|
||||
|
||||
Reference in New Issue
Block a user