/HTTPServer

Primary LanguageC#MIT LicenseMIT

HTTP Server

This is an 8th Light Apprenticeship project, built in C# and .NET.

.NET is a free, cross-platform, open source developer platform for building many different types of applications.

C# is a simple, modern, object-oriented, and type-safe programming language.

Installation:

  1. To download .NET Core, click here.
  2. This project uses .NET version 6.0.202

Run the command:

dotnet --version

to determine which version you have installed, or visit the .NET docs for more information.

  • This project started off with a simple Echo Server, and has been built out into an HTTP Server.
  • This HTTP server includes routes, requests, and responses.
  • The routes must be customizable with a URL, a verb, and an action to take when the route is called.

Functional Requirements

A user should be able to interact with the HTTP server as follows:

  • When a client sends a properly formatted request to the server, the server sends an appropriate response back to the client.
  • A client can send different HTTP requests to the server and get the appropriate response back each time.
  • Different clients can send messages to server and get back their proper responses.
  • The server should be able to handle 200, 300, and 400-level responses.
  • This server is capable of handling files, images (jpg, png, gif), XML, HTML, and JSON

Implementation Requirements

  • The server should establish a socket connection with the client using a low-level socket library.
  • The server should accept and return streams of data rather than raw strings.
  • The HTTP server should be covered by a robust suite of unit tests.
  • The HTTP server should pass all of the tests covered in the acceptance test suite

(back to top)

Run the App:

dotnet run --project TKeazirian.HTTPServer

Testing:

This project uses xUnit.net for testing.

This project also uses an acceptance test suite written using Cucumber.

Run the xUnit Test Suite:

dotnet test

Acceptance Tests:

Setup

  1. You will need Ruby version 2.5.1. You can install Ruby using brew or the Ruby docs.
  2. Once Ruby is installed, run ruby -v to confirm you are using the appropriate version.
  3. Next, run bundle install.

Run the Acceptance Tests

Note: This server is currently programmed to run on port 5000. If you would like to change the port, you can change the value of the variable, _port in Server.cs and recompile. In the future, the goal is to make this customizable via a command-line argument.

  1. Start your HTTP server (you can do this with the run the app command or click Run if you are using an IDE)
  2. Navigate into the http_server_spec folder:
cd TKeazirian.HTTPServer/http_server_spec
  1. You can run the acceptance tests with:
rake test

or

bundle exec spinach

Note: You can skip any of the acceptance tests by adding @wip to the test(s).

(back to top)