Skip to content
This repository was archived by the owner on Nov 1, 2022. It is now read-only.
This repository was archived by the owner on Nov 1, 2022. It is now read-only.

Concept component hiding (http) networking stack #1012

@pocmo

Description

@pocmo

Currently our component code uses HttpUrlConnection - mostly because that is offered by the Android System and doesn't require any third-party dependency.

However HttpUrlConnection has its issues:

  • The API doesn't really separate requests/responses and makes it unpredictable at what point it actually performs a request. It's not pleasant to use.
  • It only has a synchronous API so you almost always want to wrap it
  • It may have different underlying implementations based on Android version / flavor.

Other options are:

  • OkHttp is the de-facto standard used in Android apps. A bunch of other libraries use it internally. HttpUrlConnection is actually backed by it on newer versions of Android.
  • Necko - There has been an ongoing discussion on whether Necko can/should/will be turned into something that can live outside of Firefox. This was mostly interesting for Rust components. However with a nice Kotlin layer on top that this would be interesting for app code as well.
  • WebExecutor API in GeckoView: The GeckoView team is working on an API that allows apps using GV to send arbitrary http requests.

The reality is:

  • Apps may have different requirements.
    • An app already using GV may want to send (some) http requests through it as well (Favicons?).
    • An app already using okHttp may want to do that for component code too (because it allows them to use debugging tools like stetho).
    • An app optimized for size may want to continue using HttpUrlConnection (e.g. Rocket)
    • Apps not using GV definitely do not want to add it just for the http client.
  • Android Components do not want to force any (third-party) dependencies on apps if not absolutely necessary.

So should we:

  • Add a concept component with the necessary interfaces for doing http requests (something like fetch; concept-fetch?)

  • Provide components implementing the concept component. At least HttpUrlConnection and GeckoView?

  • Modify components doing http requests to depend on the concept component and let apps inject a dependency implementing it.

┆Issue is synchronized with this Jira Task

Metadata

Metadata

Labels

💡ideaIdeas for a new component, feature, change ..

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions