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
|
direction TB
|
||||||
|
|
||||||
class Server {
|
class Server {
|
||||||
+run()
|
+Server(const ConfigManager&)
|
||||||
+handle_new_connection(int)
|
+~Server()
|
||||||
+handle_client_event(int, int)
|
+start()
|
||||||
+setup_listeners()
|
+addToEpoll(Socket&, uint32_t)
|
||||||
+add_to_epoll(int)
|
+removeFromEpoll(Socket&)
|
||||||
+remove_from_epoll(int)
|
+setupServerSocket(ServerConfig&)
|
||||||
+std::vector<unique_ptr<Socket>> listeners_
|
+handleConnection(epoll_event*)
|
||||||
+std::unordered_map<int, unique_ptr<Client>> clients_
|
+handleRequest(epoll_event*)
|
||||||
+int epoll_fd_
|
+responseReady(int)
|
||||||
+const Configuration* config_
|
+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 {
|
class Socket {
|
||||||
+Socket(int)
|
|
||||||
+Socket()
|
+Socket()
|
||||||
|
+Socket(int)
|
||||||
+~Socket()
|
+~Socket()
|
||||||
+bind(const sockaddr_in&) int
|
+listen(int) void
|
||||||
+listen(int) int
|
+bind(string, int) void
|
||||||
+accept() Socket
|
+accept() Socket*
|
||||||
+recv(void*, size_t) ssize_t
|
+recv(void*, size_t) ssize_t
|
||||||
+send(const void*, size_t) ssize_t
|
+send(const void*, size_t) ssize_t
|
||||||
+set_non_blocking()
|
+setNonBlocking() void
|
||||||
-fd_ int
|
+getFd() int
|
||||||
|
-int _fd
|
||||||
}
|
}
|
||||||
|
|
||||||
class Client {
|
class Client {
|
||||||
+Client(unique_ptr<Socket>)
|
+Client(unique_ptr<Socket>, Server&, ServerConfig&)
|
||||||
+~Client()
|
+~Client()std::move(clientSocket), *this, getConfig(listener)
|
||||||
+process_event(int)
|
+request() void
|
||||||
+handle_read()
|
+getResponse() string
|
||||||
+handle_write()
|
-unique_ptr<Socket> client_socket_
|
||||||
+is_complete() bool
|
-Server& server
|
||||||
+unique_ptr<Socket> socket_
|
-ServerConfig& server_config
|
||||||
+unique_ptr<HTTP_Request> request_
|
|
||||||
+unique_ptr<HTTP_Response> response_
|
|
||||||
+const Server& server_
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class HTTP_Request {
|
class ConfigManager {
|
||||||
+parse_data(const std::string&)
|
+init(string)
|
||||||
+is_complete() bool
|
+getInstance() ConfigManager&
|
||||||
-method_ string
|
+getServerConfigs() vector<ServerConfig>
|
||||||
-uri_ string
|
-bool _initialized
|
||||||
-headers_ map<string, string>
|
-vector<ServerConfig> serverConfigs
|
||||||
}
|
}
|
||||||
|
|
||||||
class HTTP_Response {
|
class ServerConfig {
|
||||||
+build_from_request(const HTTP_Request&)
|
+ServerConfig(string)
|
||||||
+to_string() string
|
+getHost() string
|
||||||
-status_ int
|
+getPort() int
|
||||||
-body_ string
|
+getRoot() string
|
||||||
-headers_ map<string, 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-- "1..*" Socket : listens on
|
||||||
Server "1" o-- "0..*" Client : manages
|
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" Socket : owns
|
||||||
Client "1" *-- "1" HTTP_Request: owns
|
Client "1" -- "1" Server : references
|
||||||
Client "1" *-- "1" HTTP_Response: owns
|
Client "1" -- "1" ServerConfig : references
|
||||||
Client "1" -- "1" Server: reports to
|
ServerConfig "1" o-- "*" LocationConfig : has
|
||||||
Loading…
Reference in New Issue
Block a user