Skip to content

Conversation

@ok-nick
Copy link
Contributor

@ok-nick ok-nick commented Oct 23, 2025

This change builds off #1355 and #1444 to plumb http resolvers throughout all the internals. It also fixes a few issues with the settings plumbing and usage of sync APIs in async APIs.

The last change is removing the async-recursion dependency in favor of pinning the return of Store::ingredient_checks_async. The dependency had conflicts with usage of the http resolver traits thus leading to this change.

@ok-nick ok-nick added the check-release Add this label to any PR to invoke a larger suite of tests. label Oct 24, 2025
Copy link
Collaborator

@scouten-adobe scouten-adobe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple things to think about, but overall very happy to see this! 👍

#[cfg(not(target_arch = "wasm32"))]
pub fn from_stream(format: &str, stream: impl Read + Seek + Send) -> Result<Reader> {
let settings = crate::settings::get_settings().unwrap_or_default();
let http_resolver = if _sync {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm. I'm seeing this pattern a lot. Worth adding http_resolver and async_http_resolver accessors to settings?

Not a blocker for this PR; just a thought to explore.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I considered that approach in my ReaderBuilder PR (#1465), although I wasn't a fan for a few reasons:

  • Settings is likely to be deserialized from something, we'd either have to mark the resolver(s) as optional or default them
    • If we default them, we may be initializing an HTTP client the user will override anyways
    • If it's optional, we'd have settings represent an intermediate state when it should actually be a final state (with the resolver initialized)
  • We'd either have to add a generic or a boxed trait object to the settings struct
    • The generic would be odd when deserializing from serde
    • The boxed trait object works, but can run us into problems with Send/Sync and WASM again (and other object safety issues). Ideally we wouldn't have to heap allocate and can design an API that allows for generics (in this case separate from settings)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm thinking we add a C2paContext that can contain both, and it is the context that we pass everywhere.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes sense, I have a feeling the context could extend in the future to hold more such objects/properties too.

@scouten-adobe scouten-adobe changed the title refactor: plumb http resolver through internals refactor: Plumb HTTP resolver through internals Oct 28, 2025
// sign and write our store to to the output image file
if _sync {
store.save_to_stream(&format, source, dest, signer, &settings)
store.save_to_stream(&format, source, dest, signer, &http_resolver, &settings)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we could create the resolvers here and and simplify the code a bit.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Relating to this comment, I wonder if the http_resolver and settings here could go into a context. Since they are both needed for the execution here, and both tweak the execution.

#[cfg(not(target_arch = "wasm32"))]
pub fn from_stream(format: &str, stream: impl Read + Seek + Send) -> Result<Reader> {
let settings = crate::settings::get_settings().unwrap_or_default();
let http_resolver = if _sync {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm thinking we add a C2paContext that can contain both, and it is the context that we pass everywhere.

@scouten-adobe scouten-adobe merged commit cb89e0f into ok-nick/http-resolver Nov 5, 2025
29 checks passed
@scouten-adobe scouten-adobe deleted the ok-nick/pipe-http-resolvers branch November 5, 2025 03:48
ok-nick added a commit that referenced this pull request Nov 6, 2025
* feat: sync/async http resolvers API

* fix: impl wasi sync/async http resolvers

* fix: clean up http dependencies

* fix: clean up resolver error types and unwraps

* fix: use async generic resolver for cawg

* fix: wasi tests and compilation

* refactor: remove curl as sync http resolver

* fix: simultaneous features, lints, and ci

* fix: finish wasi and wasm impl

* ci: fix wasm features

* fix: wasm issues again

* fix: wasm issues again

* test: add generic http resolver tests

* chore: clean up unnecessary changes

* fix: do not expose http resolver in `Ingredient::from_stream_async`

* docs: document new feature flags and WASM/WASI notes

* fix: default to reqwest_blocking if ureq is also specified

* fix: simplify feature flags for generic resolvers

* ci: fix benchmarking to use proper http featuers

* ci: define env before executing command for benchmarking

* style: alphabetize http crate

* ci: fix rust native crypto jobs

* ci: revert rust_native_crypto changes for now

* docs: simplify doc references

* test: individual networking lib tests

* build: remove wasi dep from fetch_remote_manifests feature

* docs: add new features to usage.md

* fix: use concrete resolver type instead of trait object

* refactor: modularize http resolvers

* fix: resolver imports

* fix: wasm tests

* fix: reqwest_blocking import issues

* docs: remove comment stating http dependency can be optional

* docs: clarify why we use certain http features in ci

* docs: fix grammar

* ci: add http features to release readiness

* ci: run benchmarks with minimal featuers

* fix: dependencies and test caused by merge

* fix: allow timestamp assertion to be fetched on WASM

* fix: support timestamping on WASM/WASI

* fix: remove forbidden HOST header for WASI networking

* docs: remove review note

* fix: use write_all for WASI to bypass 4096 byte limit

* fix: pipe http resolvers through timestamping

* fix: default to ureq instead of reqwest_blocking until async tests are fixed

* fix: WASM http resolver for timestamps

* ci: use all features instead of excluding reqwest_blocking since we default to ureq

* feat: add `default_http` feature for simplification

* fix: add default_http as a feature of ffi and make test images

* feat: add networking feature flag for c2patool

* Capitalize HTTP consistently

* Capitalize HTTP consistently

* fix: add back http crate and fix mut variable

* refactor: Plumb HTTP resolver through internals (#1513)

* fix: pass http resolver to archive code, fix clippy lint, allow more timestamp fuctions for wasm

* style: fix formatting to nightly

---------

Co-authored-by: Eric Scouten <[email protected]>
ribhavh pushed a commit to ribhavh/c2pa-rs that referenced this pull request Nov 11, 2025
* feat: sync/async http resolvers API

* fix: impl wasi sync/async http resolvers

* fix: clean up http dependencies

* fix: clean up resolver error types and unwraps

* fix: use async generic resolver for cawg

* fix: wasi tests and compilation

* refactor: remove curl as sync http resolver

* fix: simultaneous features, lints, and ci

* fix: finish wasi and wasm impl

* ci: fix wasm features

* fix: wasm issues again

* fix: wasm issues again

* test: add generic http resolver tests

* chore: clean up unnecessary changes

* fix: do not expose http resolver in `Ingredient::from_stream_async`

* docs: document new feature flags and WASM/WASI notes

* fix: default to reqwest_blocking if ureq is also specified

* fix: simplify feature flags for generic resolvers

* ci: fix benchmarking to use proper http featuers

* ci: define env before executing command for benchmarking

* style: alphabetize http crate

* ci: fix rust native crypto jobs

* ci: revert rust_native_crypto changes for now

* docs: simplify doc references

* test: individual networking lib tests

* build: remove wasi dep from fetch_remote_manifests feature

* docs: add new features to usage.md

* fix: use concrete resolver type instead of trait object

* refactor: modularize http resolvers

* fix: resolver imports

* fix: wasm tests

* fix: reqwest_blocking import issues

* docs: remove comment stating http dependency can be optional

* docs: clarify why we use certain http features in ci

* docs: fix grammar

* ci: add http features to release readiness

* ci: run benchmarks with minimal featuers

* fix: dependencies and test caused by merge

* fix: allow timestamp assertion to be fetched on WASM

* fix: support timestamping on WASM/WASI

* fix: remove forbidden HOST header for WASI networking

* docs: remove review note

* fix: use write_all for WASI to bypass 4096 byte limit

* fix: pipe http resolvers through timestamping

* fix: default to ureq instead of reqwest_blocking until async tests are fixed

* fix: WASM http resolver for timestamps

* ci: use all features instead of excluding reqwest_blocking since we default to ureq

* feat: add `default_http` feature for simplification

* fix: add default_http as a feature of ffi and make test images

* feat: add networking feature flag for c2patool

* Capitalize HTTP consistently

* Capitalize HTTP consistently

* fix: add back http crate and fix mut variable

* refactor: Plumb HTTP resolver through internals (contentauth#1513)

* fix: pass http resolver to archive code, fix clippy lint, allow more timestamp fuctions for wasm

* style: fix formatting to nightly

---------

Co-authored-by: Eric Scouten <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

check-release Add this label to any PR to invoke a larger suite of tests. safe to test

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants