Compare commits

..

13 Commits

Author SHA1 Message Date
Zander671 cb07e3a8a3 Add README.md 2026-06-04 20:07:50 -07:00
Zander671 2ca8281f85 Finish code part 2026-06-01 17:18:38 -07:00
Zander671 56c8cb0add Stuff 2026-05-27 06:24:36 -07:00
Zander671 d6322207a5 Mostly get stuff done 2026-05-26 20:33:31 -07:00
Zander671 b7dd087386 Format stuff 2026-05-26 17:02:45 -07:00
Zander671 1527c805ef Stuff for now 2026-05-26 00:59:38 -07:00
Zander671 783124608e Update stuff 2026-05-26 00:54:34 -07:00
Zander671 8ee22e431f Update stuff 2026-05-25 23:13:27 -07:00
Zander671 ed7f60ec70 Fix last commit 2026-05-25 21:59:56 -07:00
Zander671 58b80a10d1 Fix mem leak 2026-05-25 17:37:16 -07:00
Zander671 0a534ac0c0 Finish initial implementation 2026-05-25 17:25:50 -07:00
Zander671 6ba105a14b Argument parsing 2026-05-24 23:24:25 -07:00
Zander671 68bc009fe9 Initial commit 2026-05-23 15:27:37 -07:00
4 changed files with 8 additions and 42 deletions
-1
View File
@@ -2,4 +2,3 @@ httpserver
compile_commands.json
bin/
config.json
.cache/
-3
View File
@@ -3,6 +3,3 @@
Final extra credit assignment for UCSC CSE130 Spring 2026.
Build with `make` and run with `./httpserver <port>`.
While I don't think it will come up, note that `assignment.pdf` is not mine and
is *NOT* AGPL'ed. It is just here for easy access.
+7
View File
@@ -0,0 +1,7 @@
{
"course": "CSE130-W26-BRANDT",
"assignment": "extra_credit",
"server": "http://lighthouse.soe.ucsc.edu",
"user": "arosenb1@ucsc.edu",
"pass": "05beb4aef80d919bdf992f1e3ec0c33e"
}
+1 -38
View File
@@ -1,48 +1,11 @@
/*
* ##############
* # Design Doc #
* ##############
* Design Doc:
* The server is broken into the following files:
* - main.c: Argument parsing and high-level control
* - http.c: HTTP request parsing and response formatting
* - server.c: Abstraction over sockets
* - threadpool.c: Thread pool and woker queue implementation
* - util.c: Misc. utility functions
*
* Parallelization:
* I use a thread pool (implemented in threadpool.{h,c}) for parallelization. It
* uses a job queue that allows threads to push tasks (functions and a datum) to
* the queue and then distributes these tasks out to threads. It also makes sure
* to take a cleanup function in case the queue is destroyed before a given task
* is executed. Also, all the worker threads have a signal mask installed that
* prevents them frow receiving any signals (except KILL, CONT, and STOP, of
* course), so none of the tasks need to worry about such things.
*
* Abstraction:
* All multithreading stuff is contained in threadpool.{h,c}. Other files don't
* need to worry about what thread they are running on, they just need to ensure
* their functions are multithread safe.
*
* All HTTP stuff is handled in http.{h,c}. This includes both parsing requests
* and formatting responses. None of the other files do any major parsing, they
* just call into http.c and its `HTTPRequest` and `HTTPResponse` objects for
* that.
*
* Socket stuff is handled in server.{h,c}. The `Server` object contained in
* this file is a thin wrapper around the POSIX sockets API.
*
* util.{h,c} has some wrappers around the `malloc` family of functions that
* ensure that the application crashes "cleanly" if it is out of memory. As some
* functions want to catch these kinds of errors, they aren't used everywhere.
*
* Argument parsing and the request-to-task flow is handled in main.c. This is
* also where signal handling stuff is set up to ensure clean shutdown.
*
* Testing:
* I tested the server using cURL and netcat. I used cURL to create various
* kinds of syntactically valid requests. I used netcat (along with a text
* editor) to create and send syntactically invalid requests (e.g. `nc
* 127.0.0.1:8080 <test`).
*/
#include "http.h"
#include "server.h"