A minimal but flexible directory listing server
Find a file
Laslo Hunhold 58d0f44e03
Refactor http_send_response() into http_prepare_response()
The function http_send_response() did too much. It not only took
the request fields and built them together into a response, it
delegated too little and many functions were "hacked" into it, for
instance shady directory-changes for vhosts and hand-construction
of response structs.

The preparations for a rework were already made in previous commits,
including a tighter focus on the response-struct itself. Instead of
doing everything locally in the http_send_response() function, the
new http_prepare_response() only really takes the request-struct and
builds a response-struct. The response-struct is expanded such that
it's possible to do the data-sending simply with the response-struct
itself and not any other magic parameters that just drop out of the
function.

Another matter are the http_send_status()-calls. Because the
aforementioned function is so central, this refactoring has included
many areas. Instead of calling http_send_status() in every error-case,
which makes little sense now given we first delegate everything through
a response struct, errors are just sent as a return value and caught
centrally (in serve() in main.c), which centralizes the error handling
a bit.

It might look a bit strange now and it might not be clear in which
direction this is going, but subsequent commits will hopefully give
clarity in this regard.

Signed-off-by: Laslo Hunhold <dev@frign.de>
2020-08-22 23:20:00 +02:00
arg.h Correct arg.h license 2018-07-16 11:49:51 +02:00
config.def.h Specify UTF-8 for non-binary content-types 2019-01-02 17:04:23 +01:00
config.mk Be extra pedantic again and remove all warnings 2018-03-05 00:30:53 +01:00
http.c Refactor http_send_response() into http_prepare_response() 2020-08-22 23:20:00 +02:00
http.h Refactor http_send_response() into http_prepare_response() 2020-08-22 23:20:00 +02:00
LICENSE Use timegm() instead of mktime() to generate UNIX-timestamp 2020-07-23 16:48:34 +02:00
main.c Refactor http_send_response() into http_prepare_response() 2020-08-22 23:20:00 +02:00
Makefile Refactor the single source file into multiple modules 2018-02-04 21:27:33 +01:00
quark.1 Update manpage to list capabilities and behaviour 2020-08-18 08:46:52 +02:00
resp.c Refactor http_send_response() into http_prepare_response() 2020-08-22 23:20:00 +02:00
resp.h Refactor http_send_response() into http_prepare_response() 2020-08-22 23:20:00 +02:00
sock.c Ensure const-correctness where possible and refactor parse_range() 2020-08-05 18:28:21 +02:00
sock.h Ensure const-correctness where possible and refactor parse_range() 2020-08-05 18:28:21 +02:00
util.c Refactor http_send_response() into http_prepare_response() 2020-08-22 23:20:00 +02:00
util.h Refactor http_send_response() into http_prepare_response() 2020-08-22 23:20:00 +02:00