Skip to content
tkuramot edited this page Mar 6, 2024 · 4 revisions

class

classDiagram
  Server ..> IOTaskManager: uses
  Server ..> ConfigParser: uses
  Server -- Accept: creates
  IOTaskManager --* Accept
  IOTaskManager --* ReadRequest
  IOTaskManager --* WriteResponse
  Accept --|> IOTask
  ReadRequest --|> IOTask
  WriteResponse --|> IOTask
  ReadRequest ..> RequestParser: creates
  ReadRequest ..> RequestHandler: uses
  RequestHandler ..> HTTPRequest
  RequestHandler ..> HTTPResponse: creates
  class Server {
    +Run() void
  }
  class IOTaskManager {
    -vector<IOTask> tasks_
    +Add()
    +Remove()
  }
  class IOTask {
    +Execute() = 0
  }
  class Accept {
    - port_ : string
    + Accept(int fd, const string&)
    + Execute()
  }
  class ReadRequestFromClient {
    - port_ : string
    + ReadRequestFromClient(int fd, const string& port)
    + Execute()
  }
  class WriteResponseToClient {
    - response_ : HTTPResponse* 
    + Excecute()
  }
  class RequestParser {
    +ParseRequest(str row_request) HTTPRequest **
  }
  class HTTPRequest {
    -method_ : string
    -uri_ : string
    -protocol_ : string
    -version_ : string
    -host_header_: string
    -headers_ : map<string, string> 
    -body_ : string
  }
  class RequestHandler {
    $Handle(request : HTTPRequest, port : string) const HTTPResponse* 
  }
  class HTTPResponse {
    +ToString() string

    -http_version_ : string
    -status_code_ : http::StatusCode
    -headers_ : map<string, string>
    -body_ : string
  }

  ConfigParser --> Config: creates
  ConfigParser --> ServerParser: uses
  ServerParser --> LocationParser: uses
  ServerParser --> ServerContext: creates
  LocationParser --> LocationContext: creates
  class Config {
    $ Clear()
    $ AddServer(const ServerContext& server)
    $ GetServer() 
    $ SearchServer(const std::string& port, const std::string& server_name)
    $ server_ : vector<ServerContext> 
  }
  class ConfigParser {
    $ default_file_ : string
    $ Parse(const string& file) 
  }
  class ServerParser {
    $ ParseServer(ifstream& inf)
    $ ClearParsedPair()
    - IsValidLocationKey(const vector<string>& value)
    - MakeLocationKey(const vector<string>& value)
    - ParseFuncInit(map<string, parseFunction>& func)
    $ ParseErrorPage(const vector<string>& value, ServerContext& server)
    $ ParseIndex(const vector<string>& value, ServerContext& server)
    $ ParseIp(const vector<string>& value, ServerContext& server) 
    $ ParseRoot(const vector<string>& value, ServerContext& server) 
    $ ParseServer_name(const vector<string>& value, ServerContext& server) 
    $ ParsePort(const vector<string>& value, ServerContext& server) 
    - RemoveSemicolon(string& line)
    $ parsed_root_ : bool
    $ parsed_ip_ : bool
    $ parsed_pair_ : map<string, vector<string>>
  }
  class LocationParser {
    $ ParseLocation(ifstream& inf)
    - ParseFuncInit(map<string, parseFunction>& func)
    $ ParseAutoIndex(const vector<string>& value, LocationContext& location) 
    $ ParseLimitClientBody(const vector<string>& value, LocationContext& location) 
    $ ParseReturn(const vector<string>& value, LocationContext& location) 
    $ ParseAlias(const vector<string>& value, LocationContext& location)
    $ ParseRoot(const vector<string>& value, LocationContext& location)
    $ ParseIndex(const vector<string>& value, LocationContext& location)
    $ ParseCgiPath(const vector<string>& value, LocationContext& location)
    $ ParseCgiExtention(const vector<string>& value, LocationContext& location)
    $ ParseAllowMethod(const vector<string>& value, LocationContext& location) 
    $ ParseErrorPage(const vector<string>& value, LocationContext& location)
    - RemoveSemicolon(string& line)
    $ parsed_auto_index_ : bool
    $ parsed_limit_client_body_ : bool
    $ parsed_return_ : bool
    $ parsed_alias_ : bool
    $ parsed_root_ : bool
  } 
  class ServerContext {
    - ip_ : string
    - root_ : string
    - index_ : vector<string>
    - port_ : vector<string>
    - server_name_ : vector<string>
    - error_page_ : map<string, string>
    - location_ : map<string, LocationContext>
  }
  class LocationContext {
    - can_auto_index_ : bool
    - limit_client_body_bytes_ : int
    - return_ : string
    - alias_ : string
    - root_ : string
    - index_ : vector<string>
    - cgi_path_ : vector<string>
    - cgi_extention_ : vector<string>
    - allow_method_ : map<string, bool>
    - error_page_ : map<string, string>
  }
Loading

Clone this wiki locally