Please sign in to access this page

HTTP Server

HTTP Server

22 devlogs
44h 7m
•  Ship certified
Created by Luke Barkess

An HTTP server programmed from scratch in C with no external libraries.
Native for Linux and cross-platform with Docker.

Timeline

I updated the server to handle the Connection header, I also added a response body to 404 so that the browser will display a 404 message.

Update attachment

I updated the server so that when the root target (/) is requested it can host another file such as /index.html so you can go to just 0.0.0.0:8000 without having to add the /index.html.

Update attachment

I have updated the server so that you can change the directory to host the server from. I added a Dockerfile to allow cross-platform support.

Update attachment

Ship 1

1 payout of shell 633.0 shells

Luke Barkess

2 months ago

Luke Barkess Covers 19 devlogs and 39h 41m

I again commented and cleaned up more code and implemented some more status codes. I think this might be the last update before I initially ship the project as core features have been implemented and the server can host a static website without back-end support currently. I have created a todo list in the project files for some more features that could be added, such as backend support potentially with lua implementation to allow backend configuration that the C code could interface with, this would also require me to implement more HTTP methods such as POST.

I did more refactoring and cleaning up of code, I also implemented the HEAD method. I need to still look into returning the correct status codes.

Update attachment

I reviewed and improved some more code such as making printing information better. The receiving code is now more robust for two requests received into the same buffer.

Update attachment

I just made some small edits and have been thinking on how I will fix the current client handling as it currently closes the connection after one request and response, also if one request and a second partial were received this isn't handled in the current code which could result in errors.

Update attachment

I've fixed glitches and errors in the response code and also fixed many memory leaks that were throughout the code. I've tested the server with my personal website which seems to be fully working. I need to also implement the status codes, error checking.

Update attachment

Got basic response generation and sending working which can serve a basic website with some glitches and errors, I tested with an old calculator website I made. I need to implement the correct status codes and fix some glitches.

Update attachment

Reworked response generation code to instead go from request string to request struct to response struct then finally the response string that can be sent back to the client. Whereas before I was going straight from request struct to the response string which makes the code more confusing and complicated.

Update attachment

I've done some more work on forming the HTTP response by figuring out the content type of the requested target using the file extension, this will be needed as a response field.

Update attachment

I split up my server file into multiple files as it was getting quite large. I worked on getting the value of the requested target that will be sent back to the client.

Update attachment

I started the response generation and resolving the requested target into a string value that will be returned in the response body back to the client.

Update attachment

I've finished reviewing the code and cleaning and improving it by adding comments and more error checks. Next I can form the servers response to the request and send it back to the client.

Update attachment

I've been improving the code making it cleaner and overall better, I've still got the server and main files to look at too. After that I will continue the server implementation as it currently receives and parses the request into a request data structure.

Update attachment

The HTTP request is now parsed into a struct that stores the HTTP method, the target resource, HTTP version and also all the fields as a name and value pair.

Update attachment

I've started to parse the HTTP request from the client that the server will use to send back a response. I had to do more research on some C string manipulation to convert the request string into a request struct that I will be able to use to then form a response later in development.

Update attachment

Restructured the project and split up large files into multiple. Fixed an issue where the server was binding to the loopback IP meaning other devices on my local network couldn't connect to the server. Learnt about event-driven socket programming that I may use later in development.

Update attachment

The server now properly closes sockets when they're not needed again. The server sends a test message to the client which the client receives and outputs.

Update attachment

The server now allows connecting to clients and supports multiple connections by creating child processes for each one. I've also created a simple client to test with that just connects to the server.

Update attachment

I've now started to create a server instead of a client so I need to use different socket functions to bind to a local address and then listen and accept for clients connecting. I'm also thinking about trying to run the code within a docker container too.

Update attachment

So far I have just been learning about how Linux uses sockets for networking and have been setting up a client to request data from websites before I actually create the server as that will be more complex. Currently receiving the response from the server isn't perfect so needs to be updated.

Update attachment