/Team12

Primary LanguageC++

CS130 winter 2017

Boost Http Server.

  • to build the webserver $ make compile_webserver

  • to run $ sudo ./webserver example_config

  • clean up make clean

(Tests need to be rewriten because of internal API change. Only webserver is OK to run.)

  • run unit tests (add sudo if not write permission)
$ make run_all_tests
  • run test coverage (gcov) (depends on success of $ make run_all_tests)
$ make run_test_coverage
  • run integration test
$ make run_integration_test

Code Layout

  • Config Format
    see example_config
    Currently, all path must be of one word;
    "/" will give index page (not implemented yet);

  • Creating Handlers
    Important function that parses config: get_server_parameters in server.cc
    Handlers are created and stored in a member variable in class Server called uri2handler,
    which is a std::map from uri to handler pointer. e.g. "/static" -> Hander_Static

  • Connections
    Each connection is separated into a new thread.
    In server.cc, function Server::run_server() will spawn Server::session(socket_ptr sock) into a new thread.

  • Handling Requests
    Request are received in Server::session(socket_ptr sock) in each separate thread.
    The uri is parsered in to "head" and "tail". (see additional methods in class Request in request_handler.h)
    e.g. "/static/foo/bar" => "/static" + "/foo/bar".
    "head" is used to find the corresponding handler, by looking it up in uri2handler
    (files are read into memory at once, need to consider large files later)

  • Logging
    Implemented using singleton, Logger.
    The method get_statusPage will generate a simple html status page as a string.

Docker

  • Build Docker Image
    make build_docker_image

  • Deploy to AWS
    $ ./deploy_aws.sh

  • Send request to server instance on AWS
    e.g. $ http://54.183.253.238:2020/status

  • Demo Assignment 9
    $ http://54.183.253.238:2020/static/features.md