Update class diagram: refine Server, Client, and ServerConfig classes, and add LocationConfig details
This commit is contained in:
parent
3f90d8b7ed
commit
8bc624a080
@ -2,65 +2,95 @@ classDiagram
|
||||
direction TB
|
||||
|
||||
class Server {
|
||||
+run()
|
||||
+handle_new_connection(int)
|
||||
+handle_client_event(int, int)
|
||||
+setup_listeners()
|
||||
+add_to_epoll(int)
|
||||
+remove_from_epoll(int)
|
||||
+std::vector<unique_ptr<Socket>> listeners_
|
||||
+std::unordered_map<int, unique_ptr<Client>> clients_
|
||||
+int epoll_fd_
|
||||
+const Configuration* config_
|
||||
+Server(const ConfigManager&)
|
||||
+~Server()
|
||||
+start()
|
||||
+addToEpoll(Socket&, uint32_t)
|
||||
+removeFromEpoll(Socket&)
|
||||
+setupServerSocket(ServerConfig&)
|
||||
+handleConnection(epoll_event*)
|
||||
+handleRequest(epoll_event*)
|
||||
+responseReady(int)
|
||||
+eventLoop()
|
||||
+getListener(int) Socket&
|
||||
+getClient(int) Client&
|
||||
+getConfig(int) ServerConfig&
|
||||
+getConfig(Socket&) ServerConfig&
|
||||
-int epoll_fd_
|
||||
-ConfigManager& configManager_
|
||||
-vector<unique_ptr<Socket>> listeners_
|
||||
-unordered_map<int, ServerConfig&> fdToConfig_
|
||||
-unordered_map<int, unique_ptr<Client>> clients_
|
||||
}
|
||||
|
||||
class Socket {
|
||||
+Socket(int)
|
||||
+Socket()
|
||||
+Socket(int)
|
||||
+~Socket()
|
||||
+bind(const sockaddr_in&) int
|
||||
+listen(int) int
|
||||
+accept() Socket
|
||||
+listen(int) void
|
||||
+bind(string, int) void
|
||||
+accept() Socket*
|
||||
+recv(void*, size_t) ssize_t
|
||||
+send(const void*, size_t) ssize_t
|
||||
+set_non_blocking()
|
||||
-fd_ int
|
||||
+setNonBlocking() void
|
||||
+getFd() int
|
||||
-int _fd
|
||||
}
|
||||
|
||||
class Client {
|
||||
+Client(unique_ptr<Socket>)
|
||||
+~Client()
|
||||
+process_event(int)
|
||||
+handle_read()
|
||||
+handle_write()
|
||||
+is_complete() bool
|
||||
+unique_ptr<Socket> socket_
|
||||
+unique_ptr<HTTP_Request> request_
|
||||
+unique_ptr<HTTP_Response> response_
|
||||
+const Server& server_
|
||||
+Client(unique_ptr<Socket>, Server&, ServerConfig&)
|
||||
+~Client()std::move(clientSocket), *this, getConfig(listener)
|
||||
+request() void
|
||||
+getResponse() string
|
||||
-unique_ptr<Socket> client_socket_
|
||||
-Server& server
|
||||
-ServerConfig& server_config
|
||||
}
|
||||
|
||||
class HTTP_Request {
|
||||
+parse_data(const std::string&)
|
||||
+is_complete() bool
|
||||
-method_ string
|
||||
-uri_ string
|
||||
-headers_ map<string, string>
|
||||
class ConfigManager {
|
||||
+init(string)
|
||||
+getInstance() ConfigManager&
|
||||
+getServerConfigs() vector<ServerConfig>
|
||||
-bool _initialized
|
||||
-vector<ServerConfig> serverConfigs
|
||||
}
|
||||
|
||||
class HTTP_Response {
|
||||
+build_from_request(const HTTP_Request&)
|
||||
+to_string() string
|
||||
-status_ int
|
||||
-body_ string
|
||||
-headers_ map<string, string>
|
||||
class ServerConfig {
|
||||
+ServerConfig(string)
|
||||
+getHost() string
|
||||
+getPort() int
|
||||
+getRoot() string
|
||||
+getCgiPass() string
|
||||
+getCgiExt() string
|
||||
+getErrorPages() map<int,string>
|
||||
+getIndexFiles() vector<string>
|
||||
+getLocation(string) LocationConfig&
|
||||
+getLocationPaths() vector<string>
|
||||
+setServerFD(int)
|
||||
+getServerFD() int
|
||||
-string host
|
||||
-int port
|
||||
-int server_fd
|
||||
-string root
|
||||
-string cgi_pass
|
||||
-string cgi_ext
|
||||
-map<int,string> error_page
|
||||
-vector<string> index_files
|
||||
-map<string, LocationConfig> locations
|
||||
}
|
||||
|
||||
class LocationConfig {
|
||||
+LocationConfig(string)
|
||||
-string path
|
||||
-bool autoIndex
|
||||
-string indexFile
|
||||
-map<string,string> directives
|
||||
}
|
||||
|
||||
Server "1" o-- "1..*" Socket : listens on
|
||||
Server "1" o-- "0..*" Client : manages
|
||||
Server "1" -- "1" Configuration: knows about
|
||||
Server "1" -- "1" ConfigManager : uses
|
||||
Client "1" *-- "1" Socket : owns
|
||||
Client "1" *-- "1" HTTP_Request: owns
|
||||
Client "1" *-- "1" HTTP_Response: owns
|
||||
Client "1" -- "1" Server: reports to
|
||||
Client "1" -- "1" Server : references
|
||||
Client "1" -- "1" ServerConfig : references
|
||||
ServerConfig "1" o-- "*" LocationConfig : has
|
||||
Loading…
Reference in New Issue
Block a user