Commit graph

123 commits

Author SHA1 Message Date
Ashod Nakashian
02332b54fa wsd: do not re-use incoming response for outgoing
Change-Id: I59490c11bbb9460459c3e76c472148571981fa12
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2024-07-03 11:51:14 +02:00
Henry Castro
faa23267b6 wsd: fix unused parameter ‘subjectHash’
Change-Id: I63c908361711acb496bd0a6eee5e1facec58e398
Signed-off-by: Henry Castro <hcastro@collabora.com>
2024-06-27 13:45:56 +02:00
Caolán McNamara
292e48ddf1 auto-add wopi server cert to child capath
Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: I708ae6217dc4acf3be3b80dc27a4add03e2324a0
2024-06-24 18:53:34 +02:00
Caolán McNamara
7d9d9caf2f output a warning about misconfigured servers
Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: Ia469f8c2453ff4e00025c5daad029e8d711f3cf9
2024-06-24 18:53:34 +02:00
Caolán McNamara
67c28ef9e9 show reason for connection failure if available
Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: Ic8d8e84e3dd6eb652c4a4d66cbb6ad59f94da8c5
2024-06-24 18:53:34 +02:00
Michael Meeks
216b14ee39 Send Content-Length and Connection: close to help browsers.
Possibly the combination of "gzip" and us being unhelpful about
lengths could lead to browser hangs; who can say.

Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
Change-Id: I632dfc46afde3883544292d687bdff023bccc8ac
2024-05-21 10:28:25 +02:00
Ashod Nakashian
a48917d052 killpoco: use http::Response in admin file serving
Change-Id: I9ad49002bc85071770aba08c23e0210bb10ff55b
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2024-03-19 20:51:02 -04:00
Ashod Nakashian
882350ed70 wsd: remove sendWithDateAndAgent
The explicit header entries were needed
with Poco, but since we always set them
in our http::Response constructor, these
are redundant.

Change-Id: Ifde48fd3048018747dae3e84560b31960e511a25
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2024-03-19 20:51:02 -04:00
Ashod Nakashian
cd878f3c6b wsd: expose http::Session's socket FD
For logging and informational purposes.

Change-Id: I200a54604c40351516f7947cb2bca8cf01a89c81
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2024-03-05 07:10:34 -05:00
Michael Meeks
7031c3b0ce cool#8328 - config header fixup.
config.h should be included as the 1st line in each source file.
It should not be included in headers.

config_version.h which changes on every commit should not be
included widely - so remove it from the HttpRequest heeader to
save tinderbox's ccache.

Fetch version info from helper methods rather than in-lining via
defines, to better encapsulate.

Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
Change-Id: If449a36f1ac61940f04d70d5f4180db389d9b4c4
2024-02-21 09:35:25 +00:00
Caolán McNamara
95c98805a0 cid#336284 COPY_INSTEAD_OF_MOVE
and

cid#336290 COPY_INSTEAD_OF_MOVE
cid#336288 COPY_INSTEAD_OF_MOVE
cid#336282 COPY_INSTEAD_OF_MOVE
cid#318980 COPY_INSTEAD_OF_MOVE
cid#318853 COPY_INSTEAD_OF_MOVE

Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: Icf6447b8298432359ec37242427ce595f8de4160
2024-02-08 08:49:26 +01:00
Michael Meeks
7183a3d3de spdx: improve machine and human readability of headers.
Change-Id: Ice934380029bf27054e830fffc07a5d037d1430f
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2023-11-14 19:36:31 +00:00
Ashod Nakashian
184a4a522e killpoco: replace HTTPResponse in sendFileAndShutdown
We now use our http::Response in HttpHelper::sendFileAndShutdown.

Change-Id: I77503fce7a66a11435bad896d3d5d6df611544be
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-10-24 21:33:02 -04:00
Ashod Nakashian
c3fb1d0dde wsd: helper to serialize pairs
Since we don't want to propagate Poco types
as well as our pair containers, it's best
to have these are named functions rather
than as operator<<.

Change-Id: I9772b8f314262147b6c445464bf3ce8cb598b56d
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-10-24 21:33:02 -04:00
Caolán McNamara
c6b0eebbf8 cid#329408 Unchecked return value from library
Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: Id034ba2e1ca9d4d3d7f7722b929063cee2f7d4e3
2023-10-17 09:48:02 +02:00
Skyler Grey
2666063040 Allow http Range header for media files
The range header allows a client to specify that they would like only
part of a file, e.g. only the first 1000 bytes of a video. When playing
video on Apple devices (Macs, iPads, iPhones etc.) this is required to
avoid Safari rejecting the video as broken. This is the first part of a
fix to embedded videos on Safari.

This commit does not implement specifying multiple ranges at once (e.g.
bytes=0-9,-100 to get the first 10 and last 100 bytes).

This feature is necessary to play video on Apple devices, but it is not
sufficient. In particular, I believe some further client-side fixes will
be needed to make the video play properly.

Signed-off-by: Skyler Grey <skyler.grey@collabora.com>
Change-Id: Id89a06d374b7d0efbf2b3184d8618df61684dcb6
2023-10-11 15:09:15 +00:00
Ashod Nakashian
4865eff4a0 wsd: improved assertion
Change-Id: I8d65850415f62a6b1680d6638b0639f2642d95e8
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-09-25 19:29:12 -04:00
Caolán McNamara
461fe6a630 cid#318940 Big parameter passed by value
newRequest is always called with a const Request& already so might as
well make this copy inside the function rather than passing a copy
by value and moving it.

Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: Ib572637d29590b8b470a42da3293065ed86d7dd0
2023-08-15 15:09:36 +02:00
Caolán McNamara
6062342827 cid#318980 COPY_INSTEAD_OF_MOVE
iss ctor takes a const std::string& and constructs with a copy of str as content

Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: I2805c869cb034a9b87e6e95cc58419b54a078b63
2023-08-15 08:21:44 +02:00
Caolán McNamara
b6f87b06e3 cid#322475 COPY_INSTEAD_OF_MOVE
configure currently requires a min of c++17

Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: I613dac6e66c3e77183d46623346969179bccc489
2023-08-10 08:47:25 +02:00
Ashod Nakashian
67dd4e4a9d wsd: test: new cool.html post request test
Using our own http library, we request
cool.html with realistic parameters and
validate many key values sent in the
request.

Change-Id: Ie3c0ac042f64bf5d6ed21354a33efac801b32846
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-08-03 08:40:20 +02:00
Ashod Nakashian
5e343d9ffb wsd: serialize the http status-code numerically too
Change-Id: Ia5d67f295ce0426b160b64b72399950cc3723d7b
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-07-08 04:19:00 -04:00
Ashod Nakashian
481d3b6842 wsd: http: avoid capturing locals by reference
Fortunately, we have no need for any locals
in this case.

Change-Id: I954953bb2a8c79662152ad4cc2fb5422bc2b0baa
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-06-30 21:45:40 +02:00
Ashod Nakashian
826451b6cf wsd: http: protect against exceptions from onFinish
Previously, we didn't expect such exceptions,
but increasingly this can happen, as we have
more and more async processing. The main
issue with not catching exceptions is that
we do not properly discard read and
parsed data from the socket. This is a
major issue, of course.

Change-Id: I4490baed7069cd55d103301c1d3be31d9b2d9b2c
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-06-30 21:45:40 +02:00
Caolán McNamara
c7c2644b9b fix android ci
github_android_online_co-23.05/net/HttpRequest.hpp:1391:63: error: no matching function for call to 'min'
                      << Util::dumpHex(std::string(data.data(), std::min(data.size(), 256UL))));
                                                                ^~~~~~~~

Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: I5b81096c696565b9e4eb4f3ca39c16bc1e5b9182
2023-06-26 17:07:35 +01:00
Caolán McNamara
2f9c9396d3 cid#318856 Uninitialized scalar field
Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: I2a6c3e9d021884b898f9efdc51c528428321d6f0
2023-06-14 10:10:46 +02:00
Ashod Nakashian
685e2fb0b8 wsd: http: return const& from const response getter
Change-Id: I5dc5282938a472148148d1dd6d009261bc09c7d6
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-05-22 09:34:29 -04:00
Ashod Nakashian
7ce18c8a13 wsd: http: cosmetic and log
Change-Id: I984ad71601b92b8042dc7984e7339f0804c8083b
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-05-22 09:34:29 -04:00
Ashod Nakashian
a6551462e2 wsd: http: improved http::Session::handleIncomingMessage
The normal path is now streamlined and error handling
is at the end. We also now always set the disposition
to closed and fire onDisconnect() when disconnected
or hit an error.

Change-Id: I984ad71601b92b8042dc7984e7339f0804c8083b
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-05-15 19:14:21 -04:00
Ashod Nakashian
d4b27f6643 killpoco: replace HTTP status codes
We use our own status codes, which
are type-safe and use streaming
operators to serialize and log.

Change-Id: I0eba7b16694866b5a79476a7ef4b1b78f7f9c176
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-05-11 07:21:42 -04:00
Ashod Nakashian
72cff36195 wsd: move streaming operator overloads
This is needed to correct overload
resolution of these operators.

Change-Id: I02c0859674efe112102a8d3833bfb0a30b1a6574
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-05-10 08:46:11 -04:00
Ashod Nakashian
0182af7a4a wsd: http: native support for logging http::Header
Change-Id: I8c34531e6f2616d98a4ee75fe8490d4ad25c45a9
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-05-10 08:46:11 -04:00
Ashod Nakashian
4089302362 wsd: better socket logging
Change-Id: I31b64ce1f174896a3bcfa5cd620e0babd7f425d1
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-04-14 11:30:14 +01:00
Ashod Nakashian
9596d5a0ab wsd: http: set http::Request log context
Change-Id: Ic8b9c1e7526ebf2f7c69f47f1bd98fdb9fc471ce
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-03-14 15:46:48 +01:00
Ashod Nakashian
903bb76c36 wsd: fix DEBUG_HTTP in HttpRequest
Change-Id: Iebc61b6632d33528ad362c943cb44cea56418b16
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-03-06 08:43:37 -05:00
Ashod Nakashian
e3deb96152 wsd: log the socket FD of http::Response
Change-Id: Ibd02ee6656f4db2e7b09e0b7702a6db55ec8269e
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-03-06 08:43:37 -05:00
Ashod Nakashian
8fac85b5c2 wsd: log the socket FD of http::Session
Change-Id: I9c0eb3fde6577185bce63277147a6a453311f1ec
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-03-06 08:43:37 -05:00
Ashod Nakashian
da29e2c45d wsd: log the socket number of http::Request
Change-Id: Ia0d52b38a1da73ae92765169d5e5064015dc7f40
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-03-06 08:43:37 -05:00
Ashod Nakashian
b9eb4111ae wsd: http: define named HTTP status codes
This replaces the hard-coded status-code
numbers with named compile-time constants.

Change-Id: Ibe678fb2c533b29efd696e4430f5377523eeb298
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2023-01-24 07:58:07 -05:00
Ashod Nakashian
b644904448 wsd: asyncRequest needs only wakeup its own poll thread
Apparently it woke up the world unnecessarily.

Change-Id: Iad65215da898b017860e7d7b803771f657a3e1ab
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-12-21 19:41:38 -05:00
Ashod Nakashian
7a74227164 wsd: http: improved logs
Change-Id: I075c1069b489b45283cfac75d8c8c90543a10644
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-11-28 12:50:36 +01:00
Michael Meeks
ac1c386c37 Tag polls correctly as running synchronously in the client thread.
This avoids wakeup warning us that the thread is not started to wakeup.

Change-Id: Ifd5c483717024cb1c30521433d0d10acead01e2f
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
2022-11-21 18:54:35 -05:00
Ashod Nakashian
7bf0e980bb wsd: http: correct written data-size reporting
Change-Id: I9268b0c8bd99c1f06d20916503f7df7cdbde0cc4
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-11-21 08:45:34 -05:00
Ashod Nakashian
76ac5d09c2 wsd: support embedded media
Change-Id: I28c1a813bad22c49ae759b89ad90e377890acddb
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-10-25 09:16:36 +02:00
Aron Budea
c4975d01e5 Split config.h into separate headers to avoid extensive rebuild
Eg. if only the version was changed, config.h was updated, and
everything was recompiled.

New structure, maintain these manually:
config.h.in - for configured variables that are stable if
              configuration parameters are unchanged
config_version.h.in - for version/hash related variables

----
config_unused.h.in - still generated by autoheader with all
                     variables, don't use it

Signed-off-by: Aron Budea <aron.budea@collabora.com>
Change-Id: Id9a50a9f1e798a3b3814778d8683b7d7cb57bb29
2022-09-05 12:32:49 +01:00
Andras Timar
cf6e22c22c Fix typos in comments
Signed-off-by: Andras Timar <andras.timar@collabora.com>
Change-Id: I813f652b516c79f350b46317e589b91e0ef39a1a
2022-08-23 18:37:44 +02:00
Ashod Nakashian
81399bff64 fuzzers: fixup HttpEcho
This improves the performance of fuzzing
and removes the checks that can't be guaranteed.

And fixes a test failure.

Change-Id: I987fe15b098c00d9a3d60077f0581d2ef35e306c
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-08-17 08:55:12 -04:00
Ashod Nakashian
eca9b0bb4e wsd: http: check for timeout in sync requests
This should cap the loop either when we timeout
or when termination is flagged.

Change-Id: I78a6b05df99d6bac5286e4b1e4957829ea91c500
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-08-17 08:55:12 -04:00
Ashod Nakashian
a87d1ae54f wsd: add HttpEcho fuzzer
This is a full round-trip http fuzzer.
It can achieve >1000 iterations per second
on a single 2 Ghz core, even while going
through the network loopback layer.
The advantage is that more networking code
is fuzzed this way, including not just
the http code, but also the sockets.

Change-Id: I75d21bd0e25221ee6621097a2605d62c4bb2ae4d
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-08-17 08:55:12 -04:00
Aron Budea
d30b423c07 Replace #ifdef-s with #if-s, and enable -Wundef
...for variables coming from configure.ac.

Signed-off-by: Aron Budea <aron.budea@collabora.com>
Change-Id: I39ebd21c4cb56d2a3bd38fdc35dc59b5f1fd4b49
2022-08-03 11:07:38 +02:00