Coder Social home page Coder Social logo

cfug / diox Goto Github PK

View Code? Open in Web Editor NEW
138.0 138.0 10.0 3.76 MB

A powerful HTTP package for Dart/Flutter, which supports Global settings, Interceptors, FormData, Aborting and canceling a request, Files uploading and downloading, Requests timeout, Custom adapters, etc.

Home Page: https://diox.cn

License: MIT License

Dart 85.68% Java 0.04% Objective-C 0.23% Shell 0.20% Kotlin 0.04% Ruby 0.79% Swift 0.34% CMake 5.52% C++ 6.18% C 0.42% HTML 0.54%
adapter cancellable dart dio flutter http interceptor network timeout transformer

diox's People

Contributors

alexv525 avatar britov avatar clown139880 avatar cvlnomen avatar dependabot[bot] avatar endebert avatar etet2007 avatar harsimranmaan avatar hongyiweiwu avatar insofan avatar ipcjs avatar jgoyvaerts avatar kuhnroyal avatar passsy avatar riven-spell avatar rodion-m avatar scroollocker avatar talisk avatar tarekkma avatar themisir avatar trevorwang avatar tshinezheng avatar ueman avatar vovastelmashchuk avatar weikx avatar wendux avatar wprater avatar wzslr321 avatar yebgi83 avatar yfdyh000 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

diox's Issues

The statusCode in the exception capture response is null

Package

diox

Version

5.0.0-dev.3

Output of flutter doctor -v

[✓] Flutter (Channel stable, 3.3.10, on macOS 13.1 22C65 darwin-arm, locale
    zh-Hans-CN)
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.1)
[✓] Xcode - develop for iOS and macOS (Xcode 14.2)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2021.3)
[✓] IntelliJ IDEA Ultimate Edition (version 2022.3.2 Preview)
[✓] IntelliJ IDEA Ultimate Edition (version 2022.3.2)
[✓] IntelliJ IDEA Ultimate Edition (version 2022.3.1)
[✓] VS Code (version 1.74.2)
[✓] Proxy Configuration
[✓] Connected device (3 available)
[✓] HTTP Host Availability

• No issues found!

Dart Version

2.18.6

Steps to Reproduce

image

  1. Request an API
    example: https://xxxxxxx.cn/rest/V1/mstore/orders
  2. Return 401 status code
  3. DioError.response.statusCode is null

image

Expected Result

e.response?.statusCode return 401 code

Actual Result

e.response?.statusCode return null

Proposal for a forked dio package / 关于建立一个新 dio package 的提案

Summary

dio is one of the most popular packages in Dart / Flutter's ecosystem; it has had many contributors since 2018. The key fact is, this project is usually outdated and lacks maintenance, even though it added a couple of maintainers after #1234. In order to keep it maintained, we decided to start a fork of the package as "diox" and bring it back to life.

Who we are

We are members from CFUG, maintainers of localization projects in China including flutter.cn and dart.cn. Our members include Flutter GDE, developers that actively contribute to Flutter communities, and engineers who use Flutter in their work.

Background

Supply Chain Security Concerns are becoming increasingly prominent, we need to work together to build a safer Dart / Flutter ecosystem. These top libraries, which are usually used in many Apps, should have this awareness even more.

Unfortunately, we didn’t see it meet the developers’ expectations in this project. The organization (so-called FlutterChina) claims they will continually pursue "providing valuable resources", which we didn’t think the current state of maintenance as it is now is achieving what the slogan is intended to achieve --there are several issues related to outdated codes, lacking maintenance, etc.

To build a safe, active Dart / Flutter ecosystem, after careful consideration and long-term discussions, we decided to “hard fork” the existing dio package to "diox".

Commitment

For dio:

  • Fix existing or new critical issues and bugs in the next 6 months (until June 2023) of the existing dio package.

For diox:

  • We'll triage issues if they contain essential information or reproducible steps. If issues are critical, users can provide statistics to prove their importance to help issues get prioritized ASAP.
  • Actively adapt new Flutter versions.
  • Follow the lints package of linter rules requirement.

Contributions

Open-source projects are full of challenges, this is a common sense of open-source contributors and people who benefit from open-source projects. In addition, the maintenance of open source is not easy. We understand that the organizer and collaborators won't always be actively involved with projects, but keeping projects transparent to the community, allowing developers to participate, and letting collaborators have more permissions would be a better way.

The overall contribution rules of the project are:

  • For the contributions, fixes and improvements are generally welcomed if they're well-tested, new features should provide more details to allow maintainers to understand the proposal as quickly as possible. Generally, technical support is not provided for issues and PRs.
  • For people who want to be collaborators, the scores are by calculating helpful issue comments, PR reviews, and merged PRs count for the "contribution rates", any contributions that match the rates can post a thread in the discussions to nominate as a collaborator, and will be promoted once half of the original collaborator is approved.

Credits

We appreciate all the contributions made by the initiators and maintainers of dio in the past, and hope that the new project will have more supporters and contributors. Thank you for the help and participation of every community member!

We have completed part of the work on this proposal, as well as launched the first release v5.0.0-dev.1.

Please respond with 👍 if you think it's a great proposal, or are willing to support us, please let us know if you have any suggestions in the comment.

(The English version is translated by the Chinese version.)

综述

dio 是一个在 Flutter 生态中非常流行的网络请求库,自 18 年初开源发布并持续有来自全球的开发者参与贡献。我们发现,这个项目并不是持续地在维护,一些关键问题的 Issue 和 PR 已经许久没有得到响应。因此,这个提案的目标是通过创建 diox(以 dio 为基础代码的分叉版本)来替代 dio。

我们是谁

我们是 CFUG 社区的成员,是 Flutter.cn 和 Dart.cn 文档本地化的发起人和主要维护者,成员们包括谷歌官方认可的 Flutter GDE、活跃在 Flutter 各个社区的开发者、在公司工作中使用 Flutter 的工程师们等。

背景

供应链安全问题日益凸显,我们需要共同努力构建一个更安全的 Flutter 生态,其中一个重要议题是第三方库的维护和更新。很显然,对待 dio 这样一个相当基础并且流行的库,作为使用者,我们应该对它的维护提出更高的期望。

较为可惜的是,我们没有从 dio 项目中看到期望中该有的样子,其组织所宣称的始终坚持“提供有价值的资源”也鲜有做到,包括之前有社区成员们反馈的文档内容过期等问题,此处不再一一列举。

为了整个 Flutter 社区的活跃和生态系统的安全,我们正式提出 diox 这个项目提案,diox 是一个 Dart HTTP 请求库,是以 dio 为基础代码的分叉版本。

承诺

  • 6 个月内,对 dio 中严重的 bug 承诺进行修复,你也可以直接在我们的 repo 里发 issue 提出 dio 的 bug
  • 在 Issue 中完整提供信息和复现步骤等,并使用客观数据说明影响程度,我们承诺尽快分类并解决
  • 新功能开发: 积极适配和测试最新 Flutter 版本、积极探索关于 http 新特性的实现并响应使用者的需求
  • 相较于新功能开发,我们倾向于保证这个库会被持续积极维护
  • 遵守 Dart lint package 要求

社区参与

开源项目的维护充满了挑战,这是每一位贡献过开源项目或从开源项目中受益的开发者们的共识,并且,开源社区的治理并非易事,我们非常理解项目的发起方并非能在每个阶段都保持积极参与,但相对来说,保持对社区透明、广泛吸收开发者参与以及下放部分管理权是一个相对较为妥当的组织方式。

我们计划根据 Issue 分类的数量、PR 合并的比例和 PR review 的数量计算贡献度,任何达到贡献度的贡献者均可发 Discussion 帖提名或被提名成为 diox repo 管理员和 package 管理员,过半现有维护者同意即可添加为管理员。

致敬

我们对过去阶段 dio 的发起人和维护者所做出的所有贡献表示认可和赞赏,也希望新的库能够有更多的支持者和贡献者,谢谢每一位社区成员的帮助和参与!

以上是我们这个提案的全部内容,英文内容从中文翻译而来,如果有任何出入,以中文版为主,针对这个提案,我们已经完成了 一部分工作,同时也发布了第一个版本: v5.0.0-dev.1,如果你支持这个提案,请使用 👍 来回应。如果你有任何其他建议,也欢迎留言告诉我们。

Related project section still points to original dio repository

The "Related project" section in the diox readme still points to the original dio repository:

### Related Projects

Welcome to submit third-party plugins and related libraries
in [here](https://github.com/flutterchina/dio/issues/347).

Maybe we should create an issue template for that case? Or we just remove that section? What are your opinions?

More documention on using this as a replacement/fork of dio

Request Statement

The readme says: To use diox as a dio's fork, use dependency_overrides in your pubspec.yaml: ...

Can you add more documentation around the dio branch, how it differs from the main branch, when it is updated etc?

Is it intended as a version of diox that is compatible as a dio replacement?

Solution Brainstorm

No response

Add built-in support for background JSON deserialization

Request Statement

When using Dart 2.19, we can make use of Isolate.run which also powers Flutters compute method. Since that method is contained in the Dart runtime, we can put that functionality directly into dio. Maybe when migrating to Dart 3 is a good time to to add this.

Solution Brainstorm

Use Isolate.run() for JSON deserialization on io platforms.

In order to not add significant overhead for small amounts of data, there can be a size check similar to this method from the Flutter code base:

Future<String> loadString(String key, { bool cache = true }) async {
  final ByteData data = await load(key);
  if (data == null) {
    throw FlutterError('Unable to load asset: $key');
  }
  // 50 KB of data should take 2-3 ms to parse on a Moto G4, and about 400 μs
  // on a Pixel 4.
  if (data.lengthInBytes < 50 * 1024) {
    return utf8.decode(data.buffer.asUint8List());
  }
  // For strings larger than 50 KB, run the computation in an isolate to
  // avoid causing main thread jank.
  return compute(_utf8decode, data, debugLabel: 'UTF8 decode for "$key"');
}

Maybe background processing can also be used for other calls like downloading files?

Random fails during tests with `httpbin.org`

Request Statement

https://httpbin.org/ seems can easily fail during tests with GitHub actions, it's likely caused by too many requests at the same time, or the service is unstable, which brings two options to try to prevent failures:

  • Avoid too frequent requests.
  • Write a mock adapter/transformer/interceptor to test.

DioError doesn't implements Exception

Request Statement

There's a reason why DioError doesn't implements Exception anymore? this is leading to uncaught exceptions.

On dio package I only needed to catch Exception, with diox I need to catch Exception and DioError.

try { ... } on DioError catch (e) { ... } on Exception catch (e) { ... }

Solution Brainstorm

No response

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.