running with both options and the client connects via HTTP, a redirect
will occur instead of the authentication being granted or denied.
The code for handling a HTTPS redirect has been moved out of
process_get() and put into redirect_https() and is_https_redirect().
The latter checks if redirect_https() should be called.
When darkhttpd is running with `--timeout 0` (timeout disabled), and any
connection is idle, it will use 100% of the CPU. This happens because
`select` returns immediately when its timeout is zero, causing the main
`httpd_poll` loop to spin.
Fix this by adding a check to `httpd_poll` making `select` always
receive a `NULL` timeout when `timeout_secs` is zero.
A client making quick consecutive requests with keep-alive, such as `ab`
with `-k`, can cause the connection to become hung.
This happens because of an optimization in `http_poll` function. When a
connection state becomes `DONE`, `httpd_poll` recycles the connection
and immediately calls `poll_recv_request`. However, it doesn't handle
this resulting in the connection state becoming `DONE` again. If this
occurs, the state stays in `DONE`, and the further calls to `httpd_poll`
ignore the connection.
Fix this by calling `poll_recv_request` in a loop until the state is no
longer `DONE`.
* Enable TCP_NODELAY optimization
It looks like `TCP_NODELAY` was disabled due to the bug fixed in the
previous commit. Enabling it substantially improves keep-alive
performance with `ab`:
Before:
```
Time per request: 0.272 [ms] (mean)
```
After:
```
Time per request: 0.033 [ms] (mean)
```
* Remove keep-alive optimization from `httpd_poll`
Benchmarking with `ab` shows that bypassing `select` for keep-alive
connections in the `DONE` state doesn't significantly impact
performance. Since this optimization previously caused a bug, remove it.
Commonly found in Apache log. It adds 2 fields upon the Common Log
Format (referer and user-agent).
https://en.wikipedia.org/wiki/Common_Log_Format
It is just a matter of reordering what your were already logging with a
new date formatting.
* We are cheating because we always assume HTTP/1.1 as the request
header.
* We assume the user name is unknown.