// TODO: Team Name
Matt Dragotto, Andy Kuang, McKenna Galvin
A full HTTP web server, from the boost documentation. This code is an adapted version of the HTTP server example.
The server is currently deployed on AWS under the public IP 54.190.63.110 and port 8080. Try out some of the following links!
- Echo: http://54.190.63.110:8080/echo
- Static HTML: http://54.190.63.110:8080/static1/index.html
- Static image: http://54.190.63.110:8080/static2/ducks.jpg
- Status: http://54.190.63.110:8080/status
- SQL interface: http://54.190.63.110:8080/sql
- Project 9 design doc: http://54.190.63.110:8080/static1/design.md
(We currently don't have the proxy handler up on our AWS instance because there was a bug in the proxy handler implementation that was causing our server to crash when a favicon.ico was requested that didn't exist)
- To build and run the webserver in docker, run
make docker
- To deploy the docker image to AWS and run it, run
make aws
- To SSH into the EC2 instance, run
ssh -i webserver.pem ec2-user@54.190.63.110
(assumes you have the private key webserver.pem in the working directory)
- Edit
deploy/config
to define the port on which you want the server to run. - Run
make
to build the source code - Run server using
./webserver deploy/config
The server can be accessed via a variety of methods:
- Use your browser to view the resource (for example,
http://localhost:8080/echo
). - Use a curl request:
curl -i -s localhost:8080/echo
make integration
runs the integration test onlymake test
builds the test binaries for the individual files. You can then run each test separately, if you choose (for example,./request_handler_echo_test
)make all-tests
builds and runs all unit and integration tests
If when running the server you get an error that the port is already bound,
execute sudo lsof -i:8080
(change 8080 to whatever port number you're using).
Then find the PID of the process associated with the server and kill it using sudo kill -9 <pid>
main
: Parses the config file, initializes and runs the serverserver_options
: Struct which contains the config options specified in the config file. Passed to the server upon creation so the server can properly set up request handlersserver
: Constructs a server to listen on the specified TCP address and port, and serves up files from the given directoryconnection_manager
: Manages open connections so they may be cleanly stopped when the server needs to shut downconnection
: Represents a single TCP connection from a clientrequest_handler
: Processes a request and fills out a response (variations arerequest_handler_echo
,request_handler_static
,request_handler_notfound
, andrequest_handler_status
)request
: Represents the contents of a HTTP requestresponse
: Represents the contents of an HTTP response
We also use the following helper classes taken from the boost example:
mime_types
request_parser