]> git.seodisparate.com - c_simple_http/log
c_simple_http
5 months agoHandle multiple connections simultaneously
Stephen Seo [Mon, 4 Nov 2024 06:22:58 +0000 (15:22 +0900)]
Handle multiple connections simultaneously

This commit changes the implementationt to store connected clients
file-descriptors and to iterate through them all periodically to handle
requests and to time-out stale connections. This means that even if one
connection is in progress, the program can still handle new connections
from other clients.

Note this does this not by threads but by taking advantage of
non-blocking io to handle each connection.

Fixes https://git.seodisparate.com/stephenseo/c_simple_http/issues/8 .

5 months agoRefactor static_validate_path
Stephen Seo [Sun, 3 Nov 2024 09:20:26 +0000 (18:20 +0900)]
Refactor static_validate_path

5 months agoAdd timeout to incoming connections
Stephen Seo [Sun, 3 Nov 2024 09:11:50 +0000 (18:11 +0900)]
Add timeout to incoming connections

5 months agoFix free'd buf not being set to NULL
Stephen Seo [Sun, 3 Nov 2024 08:55:09 +0000 (17:55 +0900)]
Fix free'd buf not being set to NULL

5 months agoFix potential invalid path when fetching static
Stephen Seo [Sun, 3 Nov 2024 08:54:55 +0000 (17:54 +0900)]
Fix potential invalid path when fetching static

5 months agoProperly handle 404 when checking static-dir
Stephen Seo [Wed, 30 Oct 2024 06:52:27 +0000 (15:52 +0900)]
Properly handle 404 when checking static-dir

5 months agoUpdate README.md
Stephen Seo [Wed, 30 Oct 2024 06:41:56 +0000 (15:41 +0900)]
Update README.md

5 months agoMove test static file to "example_static_dir/"
Stephen Seo [Wed, 30 Oct 2024 06:41:07 +0000 (15:41 +0900)]
Move test static file to "example_static_dir/"

5 months agoUpdate third-party submodule SimpleArchiver
Stephen Seo [Wed, 30 Oct 2024 05:42:27 +0000 (14:42 +0900)]
Update third-party submodule SimpleArchiver

5 months agoUpdate README.md
Stephen Seo [Wed, 30 Oct 2024 05:42:00 +0000 (14:42 +0900)]
Update README.md

5 months agoFix test crashing if "xdg-mime" did not exist
Stephen Seo [Wed, 30 Oct 2024 05:29:03 +0000 (14:29 +0900)]
Fix test crashing if "xdg-mime" did not exist

5 months agoAdd option --enable-static-dir=<DIR>, use static
Stephen Seo [Wed, 30 Oct 2024 05:17:49 +0000 (14:17 +0900)]
Add option --enable-static-dir=<DIR>, use static

5 months agoUpdate c_simple_http_get_file(...) in static.c
Stephen Seo [Wed, 30 Oct 2024 04:24:36 +0000 (13:24 +0900)]
Update c_simple_http_get_file(...) in static.c

Add option to not fetch mime-type and default to
"application/octet-stream".

5 months agoAdd enum for result info when getting static file
Stephen Seo [Tue, 29 Oct 2024 05:56:52 +0000 (14:56 +0900)]
Add enum for result info when getting static file

5 months agoClose read-pipe on xdg-mime's side in static.c
Stephen Seo [Tue, 29 Oct 2024 04:45:38 +0000 (13:45 +0900)]
Close read-pipe on xdg-mime's side in static.c

The pipe probably doesn't need to be closed since it is closed by
c_simple_http and the forked process stops while it is the only other
thing with that read-pipe-fd. However, it probably would be best to
close it so that during runtime all pipe fd's are closed after use.

5 months agoWork on fetching static file and mime-type
Stephen Seo [Tue, 29 Oct 2024 03:42:24 +0000 (12:42 +0900)]
Work on fetching static file and mime-type

6 months agoUpdate README.md
Stephen Seo [Thu, 26 Sep 2024 07:33:07 +0000 (16:33 +0900)]
Update README.md

6 months agoUpdate README.md
Stephen Seo [Thu, 26 Sep 2024 04:04:58 +0000 (13:04 +0900)]
Update README.md

6 months agoMerge branch 'dev'
Stephen Seo [Thu, 26 Sep 2024 03:59:27 +0000 (12:59 +0900)]
Merge branch 'dev'

Resolves https://git.seodisparate.com/stephenseo/c_simple_http/issues/3

6 months agoUpdate README.md
Stephen Seo [Thu, 26 Sep 2024 03:38:51 +0000 (12:38 +0900)]
Update README.md

6 months agoImpl. cache file lifetime checking
Stephen Seo [Thu, 26 Sep 2024 03:37:45 +0000 (12:37 +0900)]
Impl. cache file lifetime checking

By default cache files are invalidated when the are aged for longer than
1 week. This "timeout-time" can be modified with a paramter/argument.

6 months agoReload config file if cache is older than config
Stephen Seo [Thu, 26 Sep 2024 02:51:42 +0000 (11:51 +0900)]
Reload config file if cache is older than config

6 months agoSleep in test to ensure changed file timestamp
Stephen Seo [Wed, 25 Sep 2024 07:23:04 +0000 (16:23 +0900)]
Sleep in test to ensure changed file timestamp

6 months agoImpl. html cache (mostly done)
Stephen Seo [Wed, 25 Sep 2024 07:12:25 +0000 (16:12 +0900)]
Impl. html cache (mostly done)

TODO: Invalidate cache if it is too old.

6 months agobackport: Fix type set "extra" var on string part
Stephen Seo [Wed, 25 Sep 2024 04:28:42 +0000 (13:28 +0900)]
backport: Fix type set "extra" var on string part

6 months agoFix type when setting "extra" var on string part
Stephen Seo [Wed, 25 Sep 2024 04:28:42 +0000 (13:28 +0900)]
Fix type when setting "extra" var on string part

6 months agobackport: StringPart's extra type to uintptr_t
Stephen Seo [Wed, 25 Sep 2024 04:14:01 +0000 (13:14 +0900)]
backport: StringPart's extra type to uintptr_t

6 months agoUpdate example config
Stephen Seo [Tue, 24 Sep 2024 05:53:28 +0000 (14:53 +0900)]
Update example config

6 months agoChange StringPart's extra type to uintptr_t
Stephen Seo [Wed, 25 Sep 2024 04:14:01 +0000 (13:14 +0900)]
Change StringPart's extra type to uintptr_t

6 months agoImpl. c_simple_http_cache_filename_to_path(...)
Stephen Seo [Wed, 25 Sep 2024 04:10:44 +0000 (13:10 +0900)]
Impl. c_simple_http_cache_filename_to_path(...)

6 months agobackport: "Connection: close" in response headers
Stephen Seo [Mon, 23 Sep 2024 10:44:51 +0000 (19:44 +0900)]
backport: "Connection: close" in response headers

The current implementation always closes the connection after sending
the response, so it should notify the client to close the connection.

6 months agobackport: remove extra '/' in URI, config changes
Stephen Seo [Tue, 24 Sep 2024 05:53:28 +0000 (14:53 +0900)]
backport: remove extra '/' in URI, config changes

6 months agobackport: unesc. percent-encoded uri, string parts
Stephen Seo [Tue, 24 Sep 2024 04:16:34 +0000 (13:16 +0900)]
backport: unesc. percent-encoded uri, string parts

Resolves https://git.seodisparate.com/stephenseo/c_simple_http/issues/6

6 months agoUnescape percent-encoded uri when handling request
Stephen Seo [Tue, 24 Sep 2024 04:16:34 +0000 (13:16 +0900)]
Unescape percent-encoded uri when handling request

Resolves https://git.seodisparate.com/stephenseo/c_simple_http/issues/6

6 months agoUse "Connection: close" in response headers
Stephen Seo [Mon, 23 Sep 2024 10:44:51 +0000 (19:44 +0900)]
Use "Connection: close" in response headers

The current implementation always closes the connection after sending
the response, so it should notify the client to close the connection.

6 months agoImpl. alternate delimeter creating cache-filename
Stephen Seo [Mon, 23 Sep 2024 08:42:02 +0000 (17:42 +0900)]
Impl. alternate delimeter creating cache-filename

6 months agoFix use-after-free in path-to-filename function
Stephen Seo [Mon, 23 Sep 2024 06:10:39 +0000 (15:10 +0900)]
Fix use-after-free in path-to-filename function

6 months agoImpl. path-to-cache-filename, fixes to strip-path
Stephen Seo [Mon, 23 Sep 2024 05:58:28 +0000 (14:58 +0900)]
Impl. path-to-cache-filename, fixes to strip-path

6 months agoRefactor http_template to use String_Part
Stephen Seo [Mon, 23 Sep 2024 05:09:25 +0000 (14:09 +0900)]
Refactor http_template to use String_Part

6 months agoFix potential memory leak
Stephen Seo [Sun, 22 Sep 2024 10:09:07 +0000 (19:09 +0900)]
Fix potential memory leak

Fixes https://git.seodisparate.com/stephenseo/c_simple_http/issues/5

6 months agoAdd WIP html_cache
Stephen Seo [Sun, 22 Sep 2024 06:44:04 +0000 (15:44 +0900)]
Add WIP html_cache

6 months agoAdd helper to create string parts and combine them
Stephen Seo [Sun, 22 Sep 2024 06:39:35 +0000 (15:39 +0900)]
Add helper to create string parts and combine them

6 months agoMinor fix
Stephen Seo [Sun, 22 Sep 2024 05:43:28 +0000 (14:43 +0900)]
Minor fix

6 months agoAdd new arg for program: --enable-cache-dir=<DIR>
Stephen Seo [Sun, 22 Sep 2024 05:42:41 +0000 (14:42 +0900)]
Add new arg for program: --enable-cache-dir=<DIR>

6 months agoUpdate .gitignore
Stephen Seo [Sun, 22 Sep 2024 05:26:50 +0000 (14:26 +0900)]
Update .gitignore

6 months agoChange template generation: output used filenames
Stephen Seo [Sun, 22 Sep 2024 05:26:07 +0000 (14:26 +0900)]
Change template generation: output used filenames

7 months agoUpdate third-party submodule SimpleArchiver
Stephen Seo [Sat, 21 Sep 2024 09:46:21 +0000 (18:46 +0900)]
Update third-party submodule SimpleArchiver

7 months agoUse volatile for global variables
Stephen Seo [Sat, 21 Sep 2024 05:41:02 +0000 (14:41 +0900)]
Use volatile for global variables

These globals are accessed in signal handling, so they need to be
volatile.

Resolves https://git.seodisparate.com/stephenseo/c_simple_http/issues/4

7 months agoUpdate globals to use "fast" int type
Stephen Seo [Sat, 21 Sep 2024 03:02:18 +0000 (12:02 +0900)]
Update globals to use "fast" int type

7 months agoUpdate third-party submodule SimpleArchiver
Stephen Seo [Sat, 21 Sep 2024 02:59:05 +0000 (11:59 +0900)]
Update third-party submodule SimpleArchiver

7 months agoUse stdint.h types instead of int, long, etc.
Stephen Seo [Fri, 20 Sep 2024 12:45:51 +0000 (21:45 +0900)]
Use stdint.h types instead of int, long, etc.

7 months agoUpdate third_party submodule SimpleArchiver
Stephen Seo [Fri, 20 Sep 2024 12:45:18 +0000 (21:45 +0900)]
Update third_party submodule SimpleArchiver

7 months agoAdd tests for c_simple_http_strip_path(...)
Stephen Seo [Mon, 16 Sep 2024 03:04:21 +0000 (12:04 +0900)]
Add tests for c_simple_http_strip_path(...)

7 months agoFix case where URL has extra trailing '/'
Stephen Seo [Mon, 16 Sep 2024 02:20:15 +0000 (11:20 +0900)]
Fix case where URL has extra trailing '/'

7 months agoUpdate third-party submodule SimpleArchiver
Stephen Seo [Fri, 13 Sep 2024 02:40:01 +0000 (11:40 +0900)]
Update third-party submodule SimpleArchiver

7 months agoMinor fix
Stephen Seo [Thu, 12 Sep 2024 05:55:51 +0000 (14:55 +0900)]
Minor fix

7 months agoMinor fix to Makefile
Stephen Seo [Wed, 11 Sep 2024 04:28:06 +0000 (13:28 +0900)]
Minor fix to Makefile

7 months agoCI: Run unit tests on Release build as well
Stephen Seo [Wed, 11 Sep 2024 04:18:38 +0000 (13:18 +0900)]
CI: Run unit tests on Release build as well

7 months agoUpdate Makefile
Stephen Seo [Wed, 11 Sep 2024 04:11:55 +0000 (13:11 +0900)]
Update Makefile

Some cleanup.
Use certain build flags only in "RELEASE" mode.

7 months agoRevert "Update CMakeLists.txt"
Stephen Seo [Wed, 11 Sep 2024 04:03:09 +0000 (13:03 +0900)]
Revert "Update CMakeLists.txt"

This reverts commit 4aa338c9c3b75de810c5f2c28c0e797e3f2c1327.

The compiler flags added by this commit was already handled.

7 months agoUpdate CMakeLists.txt
Stephen Seo [Wed, 11 Sep 2024 04:01:09 +0000 (13:01 +0900)]
Update CMakeLists.txt

7 months agoUpdate CMakeLists.txt
Stephen Seo [Wed, 11 Sep 2024 03:58:29 +0000 (12:58 +0900)]
Update CMakeLists.txt

7 months agoAdd hardening compiler flags to Makefile
Stephen Seo [Wed, 11 Sep 2024 03:56:00 +0000 (12:56 +0900)]
Add hardening compiler flags to Makefile

7 months agoUpdate third-party submodule SimpleArchiver
Stephen Seo [Wed, 11 Sep 2024 03:49:01 +0000 (12:49 +0900)]
Update third-party submodule SimpleArchiver

7 months agoCleanup: removed unused pointer in internal struct
Stephen Seo [Tue, 10 Sep 2024 12:44:10 +0000 (21:44 +0900)]
Cleanup: removed unused pointer in internal struct

7 months agoFix potential "strlen(NULL)"
Stephen Seo [Tue, 10 Sep 2024 12:18:10 +0000 (21:18 +0900)]
Fix potential "strlen(NULL)"

7 months agoMinor refactoring/fixes
Stephen Seo [Tue, 10 Sep 2024 10:22:47 +0000 (19:22 +0900)]
Minor refactoring/fixes

7 months agoMinor refactoring
Stephen Seo [Tue, 10 Sep 2024 09:01:45 +0000 (18:01 +0900)]
Minor refactoring

7 months agoMinor refactoring
Stephen Seo [Tue, 10 Sep 2024 06:39:16 +0000 (15:39 +0900)]
Minor refactoring

7 months agoMake config reloading more robust
Stephen Seo [Tue, 10 Sep 2024 06:34:26 +0000 (15:34 +0900)]
Make config reloading more robust

7 months agoUpdate README.md
Stephen Seo [Tue, 10 Sep 2024 05:00:57 +0000 (14:00 +0900)]
Update README.md

7 months agoImpl. hot reloading of config and on SIGUSR1
Stephen Seo [Tue, 10 Sep 2024 04:55:16 +0000 (13:55 +0900)]
Impl. hot reloading of config and on SIGUSR1

Resolves https://git.seodisparate.com/stephenseo/c_simple_http/issues/2

7 months agoFix "unfixed" "count" from previous commit
Stephen Seo [Mon, 9 Sep 2024 08:01:41 +0000 (17:01 +0900)]
Fix "unfixed" "count" from previous commit

7 months agoFix typo when returning 500 error
Stephen Seo [Mon, 9 Sep 2024 07:59:46 +0000 (16:59 +0900)]
Fix typo when returning 500 error

7 months agoMinor fixes/cleanup
Stephen Seo [Mon, 9 Sep 2024 04:53:58 +0000 (13:53 +0900)]
Minor fixes/cleanup

7 months agoRefactor "print request headers"
Stephen Seo [Mon, 9 Sep 2024 03:39:47 +0000 (12:39 +0900)]
Refactor "print request headers"

Resolves https://git.seodisparate.com/stephenseo/c_simple_http/issues/1

7 months agoUpdate third-party submodule SimpleArchiver
Stephen Seo [Mon, 9 Sep 2024 02:32:05 +0000 (11:32 +0900)]
Update third-party submodule SimpleArchiver

Also fixes related to the updated third-party submodule.

7 months agoImpl. print of specific headers arg/option
Stephen Seo [Fri, 6 Sep 2024 08:30:37 +0000 (17:30 +0900)]
Impl. print of specific headers arg/option

TODO: Maybe refactor this to use a hash-map or something similar to
speed up the process. If N = number-of-headers-to-print and M =
size-of-request-buffer, then currrently this will take O(N*M) time.

7 months agoAdd flag to disable peer address printing
Stephen Seo [Fri, 6 Sep 2024 07:40:36 +0000 (16:40 +0900)]
Add flag to disable peer address printing

Minor teak in main to make Args const.

7 months agoDebug print only in Debug builds
Stephen Seo [Fri, 6 Sep 2024 07:32:47 +0000 (16:32 +0900)]
Debug print only in Debug builds

7 months agoOnly allow protocol "HTTP/1.1"
Stephen Seo [Fri, 6 Sep 2024 06:57:46 +0000 (15:57 +0900)]
Only allow protocol "HTTP/1.1"

7 months agoAdd support for different error responses
Stephen Seo [Fri, 6 Sep 2024 06:55:21 +0000 (15:55 +0900)]
Add support for different error responses

7 months agoRemove "?" or "#" starting suffixes from path
Stephen Seo [Fri, 6 Sep 2024 06:33:31 +0000 (15:33 +0900)]
Remove "?" or "#" starting suffixes from path

These suffixes may break loading the correct html template.

7 months agoUpdate third party submodule SimpleArchiver
Stephen Seo [Fri, 6 Sep 2024 05:30:33 +0000 (14:30 +0900)]
Update third party submodule SimpleArchiver

7 months agoupdate README.md
Stephen Seo [Fri, 6 Sep 2024 04:47:31 +0000 (13:47 +0900)]
update README.md

7 months agoFix warnings
Stephen Seo [Fri, 6 Sep 2024 04:43:25 +0000 (13:43 +0900)]
Fix warnings

7 months agoAdd CMakeLists.txt, update .gitignore
Stephen Seo [Fri, 6 Sep 2024 04:24:28 +0000 (13:24 +0900)]
Add CMakeLists.txt, update .gitignore

7 months agoUpdate README.md
Stephen Seo [Fri, 6 Sep 2024 04:16:31 +0000 (13:16 +0900)]
Update README.md

7 months agoAdd README.md, ensure listening port is printed
Stephen Seo [Fri, 6 Sep 2024 04:11:00 +0000 (13:11 +0900)]
Add README.md, ensure listening port is printed

7 months agoMinor tweaks/fixes
Stephen Seo [Fri, 6 Sep 2024 03:49:32 +0000 (12:49 +0900)]
Minor tweaks/fixes

Add example config using "_FILE" variables.

Increase limit of config value size from 256 to 1024.

7 months agoAdd more example.config stuff
Stephen Seo [Fri, 6 Sep 2024 03:42:18 +0000 (12:42 +0900)]
Add more example.config stuff

7 months agoFix invalid read when checking for "_FILE" vars
Stephen Seo [Fri, 6 Sep 2024 03:03:03 +0000 (12:03 +0900)]
Fix invalid read when checking for "_FILE" vars

7 months agoMinor tweak to listening port info output
Stephen Seo [Fri, 6 Sep 2024 02:56:52 +0000 (11:56 +0900)]
Minor tweak to listening port info output

7 months agoImpl. handling HTTP/1.1 requests
Stephen Seo [Fri, 6 Sep 2024 02:53:28 +0000 (11:53 +0900)]
Impl. handling HTTP/1.1 requests

TODO:
    Handle errors other than 404 Not Found.

7 months agoUse ${CC} and "CC ?= gcc" in Makefile
Stephen Seo [Thu, 5 Sep 2024 07:25:49 +0000 (16:25 +0900)]
Use ${CC} and "CC ?= gcc" in Makefile

7 months agoFix inconsistent http_template output size
Stephen Seo [Thu, 5 Sep 2024 07:18:28 +0000 (16:18 +0900)]
Fix inconsistent http_template output size

7 months agoAdd "output" size parameter to http_template fn
Stephen Seo [Thu, 5 Sep 2024 07:12:50 +0000 (16:12 +0900)]
Add "output" size parameter to http_template fn

7 months agoRemove temporary files created by unit test on end
Stephen Seo [Thu, 5 Sep 2024 05:07:42 +0000 (14:07 +0900)]
Remove temporary files created by unit test on end

7 months agoImpl. ".*_FILE" variables for templates
Stephen Seo [Thu, 5 Sep 2024 05:02:25 +0000 (14:02 +0900)]
Impl. ".*_FILE" variables for templates

If there exists a "{{{something_FILE}}}" (a variable ending with
"_FILE"), then the loaded variable will be treated as a filename and its
contents will be put in the html template.

7 months agoAdd action/workflow to run unit tests
Stephen Seo [Wed, 4 Sep 2024 08:51:07 +0000 (17:51 +0900)]
Add action/workflow to run unit tests