Commit Graph

109 Commits

Author SHA1 Message Date
Fabian Grünbichler
6a1be173a6 http: sync: derive default user-agent from crate version
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2023-03-07 09:30:13 +01:00
Fabian Grünbichler
5ba9d9b2c2 http: sync: remove redundant calls for setting User-Agent
the requests are all created via the agent that already contains the user
agent, so this internal helper isn't needed anymore.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2023-03-07 09:30:13 +01:00
Fabian Grünbichler
d69fee254a http: sync: set user-agent via ureq agent
this allows us to slim down our code, and once
https://github.com/algesten/ureq/pull/597 is merged upstream (and/or we update
to a version containing the fix) it also means the custom user agent is used
for requests to the proxy host, if one is configured.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2023-03-07 09:30:13 +01:00
Wolfgang Bumiller
d422852f51 bump proxmox-http to 0.8.0
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-03-02 16:14:04 +01:00
Wolfgang Bumiller
d7ed04f8e5 http: add RateLimitedStream::inner, drop peer_addr
instead of implementing 'peer_addr' specifically for
RateLimitedStream<tokio::net::TcpStream>, just provide
.inner() and .inner_mut() so the user can reach the inner
stream directly.

This way we can drop the tokio/net feature as well

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-03-02 16:14:04 +01:00
Wolfgang Bumiller
b2c26f74a6 http: lower hyper feature requirements for client feature
instead of 'full', we only need 'tcp+http1+http2'

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-03-02 16:14:04 +01:00
Wolfgang Bumiller
10a3ab222b http: move rate-limiting out of client feature
this can now be used separately

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-03-02 16:14:04 +01:00
Wolfgang Bumiller
b62d76e80c http: start 0.8.0 refactoring
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-03-02 16:14:04 +01:00
Fabian Grünbichler
46a675830d update d/control files
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2022-12-07 09:48:47 +01:00
Fabian Grünbichler
e5abc0590e define workspace dependencies in workspace
so that we no longer have to (or forget to) bump the version in multiple places.

notable changes:
- outdated versions have been unified
- proxmox-metrics -> proxmox-async no longer uses explicit empty features
  (proxmox-async doesn't provide any anyway)
- proxmox-subscription -> proxmox-http no longer uses explicit default_features
  = false (proxmox-http has an empty default feature anyway)
- missing path dependencies added (mainly proxmox-rest-server)

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2022-12-07 09:48:38 +01:00
Fabian Grünbichler
6c161bd5ab update d/control files
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2022-12-07 09:48:38 +01:00
Fabian Grünbichler
4189221470 inherit shared, external dependencies
noteworthy changes:
- proxmox-http had a default_features_false dep on hyper, which is dropped (the
  default feature is empty anyway)
- hyper, libc, nix, tokio and url versions are unified
- missing (cosmetic) bindgen feature on zstd enabled everywhere

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2022-12-07 09:48:38 +01:00
Fabian Grünbichler
64959d9ae0 move common metadata to workspace
and switch all crates to 2021 edition as well as a unified "authors" value.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2022-12-07 09:48:25 +01:00
Fabian Grünbichler
5ec765f842 update d/control files
debcargo 2.6 changed some minor details

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2022-12-06 11:21:43 +01:00
Fabian Grünbichler
7b350d3e43 proxmox-http: fix last changelog entry
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2022-10-19 14:17:42 +02:00
Fabian Grünbichler
5b90667d05 http: bump to 0.7.0
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2022-09-07 09:35:51 +02:00
Fabian Grünbichler
08a6d56eae http: client_trait: make request body generic
like the response body, instead of hard-coding Read.
2022-09-07 09:25:47 +02:00
Fabian Grünbichler
891dcfda2f http: add extra_headers to post
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2022-09-07 09:17:45 +02:00
Fabian Grünbichler
ec77785578 http: sync: add HttpClient for Box<dyn Read>
for use cases where the full request body is not available from the
start, or the response doesn't need to be fully read in one go.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2022-09-07 09:17:45 +02:00
Fabian Grünbichler
00f5eca155 http: make post() take Read, not &str
for more flexibility.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2022-09-07 09:17:45 +02:00
Fabian Grünbichler
7863eff2a5 http: fix typo
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2022-09-07 09:17:45 +02:00
Fabian Grünbichler
da49b98d15 http: rename SimpleHttp to Client
so we have proxmox_http::client::Client for the async, hyper-based
client and proxmox_http::client::sync::Client for the sync, ureq-based
one.

this is a breaking change.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2022-09-07 09:17:45 +02:00
Fabian Grünbichler
7ffb895062 http: add "raw" sync client
and switch String one over to use it.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2022-09-07 09:17:45 +02:00
Fabian Grünbichler
9c444d7a94 http: add ureq-based sync client
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2022-09-07 09:17:45 +02:00
Fabian Grünbichler
f429fcb592 http: extend HttpClient trait
to allow get requests with extra headers (such as `Authorization`) and a
generic `request` fn to increase flexibility even more.

this is a breaking change.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2022-09-07 09:17:45 +02:00
Fabian Grünbichler
ab5d5b39f6 http: move SimpleHttpOptions to http-helpers feature
and rename it to HttpOptions, since it's not specific to the "Simple"
client at all.

this is a breaking change.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2022-09-07 09:17:45 +02:00
Thomas Lamprecht
52a8eb6ace d/control: tree wide update after switch to weak/namespaced dependencies
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2022-08-26 12:07:36 +02:00
Fabian Grünbichler
289d297c7d build: use weak and namespaced features
to reduce the creep of optional dependencies being exposed as features.

this requires cargo 0.63 (and debcargo built against at least that
version), but greatly reduces the number of binary packages and provides
generated, while still allowing sensible selection of optional
dependencies via the explicit feature meant for pulling them in.

diff stat for running `make  deb` after this change:
 proxmox-http/debian/control         | 226 ++++--------------------------------
 proxmox-router/debian/control       |  74 +-----------
 proxmox-schema/debian/control       |  53 ++-------
 proxmox-subscription/debian/control |  17 +--
 proxmox-sys/debian/control          |  51 +++-----
 proxmox-tfa/debian/control          | 110 ++----------------
 6 files changed, 72 insertions(+), 459 deletions(-)

the 'dep:' prefix marks something on the RHS inside the features section
as dependency, it's only allowed if the string after it is an optional
dependency an no explicit feature of the same name exists. if all
pointers to the optional dependency in the features section are marked
as such, the optional dependency itself will not be exposed as a feature
(either on the cargo or debian/control level).

the '?' suffix marks dependencies as "weak", which only enables the
optional dependency + its feature(s) if the optional dependency itself
is also enabled. it has no effect on d/control since such a relationship
is not encodable in Debian package relations, but it does affect cargo
dependency resolution and allows skipping the build of unneeded optional
dependencies in some cases.

with no packages/crates depending on the no longer exposed automatically
generated features/packages, so these are safe to remove even though
it's technically a breaking change.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2022-08-26 10:35:00 +02:00
Wolfgang Bumiller
b3e2a1f574 bump d/control files
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2022-07-28 13:39:21 +02:00
Wolfgang Bumiller
2eacdbe090 bump proxmox-http to 0.6.5-1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2022-07-28 13:35:47 +02:00
Wolfgang Bumiller
1d3f4a4bbd http, shared-memory, subscription: bump proxmox-sys dependency to 0.4
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2022-07-28 13:35:47 +02:00
Wolfgang Bumiller
28ee8bc6d0 http: clippy fixes
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2022-07-27 10:52:50 +02:00
Wolfgang Bumiller
d228ef6e20 http: bump d/control
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2022-07-21 12:58:41 +02:00
Wolfgang Bumiller
dc57115703 bump proxmox-http to 0.6.4-1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2022-07-21 12:58:11 +02:00
Mira Limbeck
a8a838754d http: fix proxy authorization header to include type
and encode the username:password string as base64 [0]. This fixes the
error 407 issue when using proxy authentication [1].

[0] https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Proxy-Authorization
[1] https://forum.proxmox.com/threads/checking-the-subscription-behind-a-proxy-fails.112063/

Signed-off-by: Mira Limbeck <m.limbeck@proxmox.com>
2022-07-21 12:54:59 +02:00
Wolfgang Bumiller
94d388b988 http: clippy fixups
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2022-07-20 13:31:58 +02:00
Fabian Grünbichler
b5accff750 bump proxmox-http to 0.6.3-1 2022-06-30 12:42:18 +02:00
Fabian Grünbichler
bd1f9f103e http: implement HttpClient for SimpleHttp
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2022-06-30 12:42:17 +02:00
Fabian Grünbichler
3c0486be50 http: add HttpClient trait
gated behind feature "client-trait"

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2022-06-30 12:42:12 +02:00
Fabian Grünbichler
94456ee4b1 http: move TLS helper to client feature
it's only used there and pulls in hyper and tokio, which we don't
want/need in http-helpers.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2022-06-29 10:32:44 +02:00
Fabian Grünbichler
210d4fdb68 http: take over json_object_to_query 2022-06-29 10:32:44 +02:00
Wolfgang Bumiller
0d30720907 http: clippy fixes
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2022-06-29 10:14:33 +02:00
Fabian Grünbichler
7667e549a5 bump proxmox-http to 0.6.2
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2022-06-02 14:33:12 +02:00
Fabian Grünbichler
05d3c3f412 http: bump proxmox-sys to 0.3.0
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2022-06-02 14:33:12 +02:00
Thomas Lamprecht
42dd95aa6f http: bump version to 0.6.1-1
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2022-05-05 10:42:52 +02:00
Thomas Lamprecht
9c0e9dca59 tree wide update of genereated control
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2022-05-05 10:22:50 +02:00
Thomas Lamprecht
0eeb0dd17c http: rustfmt
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2022-04-10 12:41:21 +02:00
Wolfgang Bumiller
57d052af36 workspace: set proxmox-lang dep version to 1.1
to ensure the error macros are available

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2022-02-21 13:45:46 +01:00
Dominik Csapak
d4b4115400 move io error helpers to proxmox-lang
this removes proxmox_sys as a dependecy for proxmox-async

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2022-02-21 13:35:14 +01:00
Wolfgang Bumiller
70142e607d proxmox-http: drop 'mut' on specialized request methods
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2022-02-11 08:56:34 +01:00