Commit Graph

174 Commits

Author SHA1 Message Date
ejurgensen
4315c73775 [httpd] Fix building on FreeBSD which doesn't have SYS_gettid 2023-08-29 23:50:19 +02:00
ejurgensen
580ba924a4 [httpd] Remove needless test (always true) 2023-04-25 23:04:44 +02:00
ejurgensen
e94838925e [httpd] Change prototype for the close connection callback
Don't include hreq since it isn't fully valid, so caller shouldn't be invited
to dereference it.
2023-03-07 21:01:45 +01:00
ejurgensen
18a80f15dd [httpd] Multithread solution using worker threads instead of httpd threads
Using worker threads instead of httpd threads means that we, not libevent,
decide which requests get handled by which threads. This means that we can
make sure blocking requests (e.g. volume changes) don't get in the way of
realtime(ish) stuff like mp3 streaming.

Includes refactor of httpd_stream_file() since it was a bit of a monster.
2023-03-07 21:01:45 +01:00
ejurgensen
a2c63a5bac [httpd] Check for syscall() presence and fix small memleak 2023-03-07 21:01:10 +01:00
ejurgensen
4d0c297901 [evhtr] Consolidate pool threading in evthr.c
Also reinstate check for server already running
2023-03-07 21:01:10 +01:00
ejurgensen
bd6f38282c [httpd] Main commit that adds multithreading to httpd
Also refactor streaming implementation to make it more like an output and to
let the design support multithreading.
2023-03-07 21:01:10 +01:00
ejurgensen
50a319df2b [httpd] Try doing request handling in worker thread 2023-03-07 21:01:10 +01:00
ejurgensen
74f1b93b42 [httpd] Make http modules agnostic to evhttp 2023-03-07 21:01:10 +01:00
ejurgensen
2778088c52 [httpd] Refactor to use modules for daap, dacp, json api etc.
Removes a lot of code duplication which hopefully will make it easier to add
support for evhtp as http engine.
2023-03-07 21:01:10 +01:00
ejurgensen
23979d223c [httpd] Refactor http handlers so they are initialized centrally
Means regex.h doesn't need to be in httpd.h making it easier to e.g. experiment
with evhtp.
2023-03-07 21:01:10 +01:00
ejurgensen
5f342ea60b [httpd/artwork] Drop support for libevent <2.1.4 2023-03-07 21:01:10 +01:00
ejurgensen
c23c2fdc45 [httpd] Addendum to commit 017e09d: More fixing up of libevent warnings 2022-12-26 17:16:58 +01:00
ejurgensen
017e09d7c3 [httpd] Fix evhttp_connection_get_peer() const char warning for newer libevent 2022-12-25 20:09:38 +01:00
chme
b18b76413d [httpd] Fix parsing of uri into path parts with encoded '/' (%2F)
In path with an encoded '/' character, the parsing of the path into
parts was wrong.

E. g. an uri like
'/api/library/composers/Adam%20Gardner%2FDavid%20Schneider' would result
in the following parts:

- path_part[0] = "/api"
- path_part[1] = "library"
- path_part[2] = "composer"
- path_part[3] = "Adam Gardner"
- path_part[4] = "David Schneider"

Doing the decode after splitting the uri into parts fixes this and
results in:

- path_part[0] = "api"
- path_part[1] = "library"
- path_part[2] = "composer"
- path_part[3] = "Adam Gardner/David Schneider"
2022-03-31 20:51:00 +02:00
ejurgensen
334beb1cfa [httpd] Coverity fixups 2022-01-20 20:17:38 +01:00
Christian Meffert
3a9589c25b
Merge pull request #1282 from chme/httpd_webroot
[httpd] Dereference web root directory to allow symlinks
2021-07-09 09:56:06 +02:00
ejurgensen
d2f4efa1bf [misc] Centralize thread naming plus name websocket thread 2021-07-05 21:40:31 +02:00
chme
93b9740233 [httpd] Dereference web root directory to allow symlinks 2021-07-04 11:41:39 +02:00
ejurgensen
5f1686695a [-] Name update forked-daapd -> owntone throughout the code 2021-04-24 23:54:20 +02:00
ejurgensen
d4711decdc [httpd] Bind via misc.c's net_xxx methods 2021-03-31 23:55:25 +02:00
ejurgensen
7871d71a9c [misc] Add utility network functions, incl configurable addr binding
Also make misc.c/h a bit less messy.
2021-03-31 23:55:25 +02:00
ejurgensen
19635e61ec [httpd] Fix scan-build make warning from commit 3a03c74
Potential buffer overflow
2021-03-15 21:59:40 +01:00
chme
3a03c74f91 Deny access to files outside the web root directory 2021-03-14 09:08:16 +01:00
chme
13e8103962 [httpd/spotify] Remove redirect to legacy admin.html page 2020-11-22 10:27:10 +01:00
chme
d29f56f3eb [httpd] Add "max-age=0" to Cache-Control header to force browsers to
always revalidate cached content
2020-09-27 19:13:07 +02:00
chme
dd811e6c70 [jsonapi] Prevent browsers to cache playlist tracks
The tracks of a smart playlist might change between library rescans.
Allowing them to be cached based on the last rescan timestamp
("Last-Modified" header in the response) leads to potentially showing
incorrect track listing if a cached version is used. Thus the response
for playlist tracks should never be cached by the browser (this is
achieved with setting "Cache-Control" header to "no-store").
2020-09-27 19:13:07 +02:00
ejurgensen
5e6b5fbe8a [httpd/logger] Use gmtime_r/localtime_r instead of gmtime/localtime
gmtime and localtime are not thread safe

credit lgtm.com
2020-08-10 22:23:21 +02:00
ejurgensen
1c08b75ce5 [httpd] Improve log and error message 2020-04-15 16:00:18 +02:00
ejurgensen
5736217315 [db] Change prototype of db_admin_getxxx() functions
Makes it possible for caller to distinguish between "not set" and "set to 0".
2020-02-23 20:30:35 +01:00
chme
662bfa529b [httpd] Force browsers to always revalidate their cached versions
Setting Cache-Control to "no-cache" tells a client to always make a
request to check if the version in the client cache is still valid
(response code 403 not modified).
2019-10-26 12:01:15 +02:00
whatdoineed2do/Ray
554799ebc3 [streaming/xcode] configurable MP3 streaming bitrate 2019-09-22 22:58:32 +02:00
ejurgensen
1752901529 [misc] Change b64_* to wrap ffmpeg's base64 encoder/decoder
Using ffmpeg's is probably better than having our own, plus it provides us with
decoded length, which we will need to support artwork via pipe.
2019-09-20 21:47:17 +02:00
ejurgensen
4ab734343c [-] Free events on exit (turns out event_base_free does not free them)
Credit @whatdoineed2do, ref. pr #797
2019-09-09 22:23:00 +02:00
ejurgensen
53780a7ef3 [xcode] Make sample rate + channels variable
This change is preparation to use ffmpeg's resampling capabilities to keep local
audio in sync (by up/downsampling slightly). This requires that sample rates are
not fixed for a transcode profile.

Added benefit of this is that we don't need quite as many xcode profiles.
2019-04-02 22:47:11 +02:00
ejurgensen
41126d7be4 [artworkapi/jsonapi] Retrieve artwork for track/album/artist 2018-10-07 21:54:38 +02:00
whatdoineed2do
8b7c19a299 [httpd] allow webdir (htdocs) to be symlink to dir 2018-08-18 11:34:03 +01:00
chme
ae3e0b6bf5 [httpd] Lower log level if file is not found 2018-04-26 22:20:27 +02:00
chme
d15018cb99 [httpd/jsonapi] Add cache control headers to some json api endpoints
Adds utility functions to httpd.c for checking the request headers for
either an "If-None-Match" or an "If-Not-Modified-Since" headers. If the
header value is found and it matches the current value for the requested
resource, we return early with a http response code 403 (Not Modified).
If the request header value is not present or does not match we add the
current ETag/Last-Modified values to the response headers and process
the request normally.
2018-04-15 22:11:40 +02:00
chme
d59e62312a [httpd] Allow cross origin POST, PUT, DELETE, OPTIONS requests
If the web interface is hosted on a different server, this is required
to allow sending e. g. post/put requests to control outputs.
2018-03-14 19:12:20 +01:00
chme
a764fb3c52 [httpd] Serve index.html if requested source is a directory
Defaults to an index.html file instead of redirecting to admin.html. It
will not redirect to index.html, but instead serve the file (if exists)
directly. This allows nicer uris in the webinterface.

We will still redirect to admin.html if no index.html is found for
requests to http://ip:port/
2018-03-14 19:12:20 +01:00
chme
1379ef235c [httpd] Support assigning request methods to uri handlers 2018-02-15 19:19:13 +01:00
chme
d4b05e98ae [httpd] Add PUT and DELETE to the allowed http request methods 2018-02-10 10:39:32 +01:00
ejurgensen
4da45bdfab [httpd] Parser should allow queries that are not key/value
E.g. http://prem3.di.fm:80/progressive_hi?my_premium_key
2018-01-08 20:13:05 +01:00
chme
7083c65314 [main/httpd] Configurable web root directory over cli parameter 2017-12-03 10:46:50 +01:00
ejurgensen
a6fab4ac0d [httpd/mpd] Adjustments to commit #69ff42f 2017-11-15 23:13:20 +01:00
Wolfgang Scherer
69ff42fc6a [mpd] apply trusted_networks to MPD 2017-11-15 22:29:22 +01:00
ejurgensen
3d5aeda7aa [httpd] Implement "trusted_networks" option
Some clients aren't really capable of authenticating + some users probably
don't want to enter a password for the web interface. This option allows
clients on for instance the local network to connect without authentication.
2017-11-12 21:29:57 +01:00
ejurgensen
6d937469f5 [httpd] Decrease log level of stream complete messages 2017-11-11 22:20:09 +01:00
ejurgensen
473a29ef8a [httpd] More refactoring, reduce code duplication in the httpd_xxx modules 2017-11-11 22:20:09 +01:00