Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Non-ASCII characters in headers might cause exceptions thrown with DioExceptionType.unknown #2299

Closed
xiongzhaoxu opened this issue Sep 23, 2024 · 10 comments

Comments

@xiongzhaoxu
Copy link

Package

dio

Version

5.7.0

Operating-System

iOS, MacOS, Windows

Adapter

Default Dio

Output of flutter doctor -v

[✓] Flutter (Channel stable, 3.24.2, on macOS 14.3.1 23D60 darwin-arm64, locale zh-Hans-CN)
    • Flutter version 3.24.2 on channel stable at /Users/xiongzhaoxu/work/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 4cf269e36d (3 weeks ago), 2024-09-03 14:30:00 -0700
    • Engine revision a6bd3f1de1
    • Dart version 3.5.2
    • DevTools version 2.37.2
    • Pub download mirror https://pub.flutter-io.cn
    • Flutter download mirror https://storage.flutter-io.cn

[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.1)
    • Android SDK at /Users/xiongzhaoxu/Library/Android/sdk
    • Platform android-34, build-tools 33.0.1
    • Java binary at: /Applications/Android Studio 2.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b829.9-10027231)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 15.4)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 15F31d
    • CocoaPods version 1.15.0

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2022.3)
    • Android Studio at /Applications/Android Studio 2.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b829.9-10027231)

[✓] IntelliJ IDEA Ultimate Edition (version 2023.3.4)
    • IntelliJ at /Applications/IntelliJ IDEA 2.app
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart

[✓] VS Code (version 1.93.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.90.0

[✓] Connected device (4 available)
    • iPhone 11 (mobile)              • 00008030-00160CDE0E50802E • ios            • iOS 17.3.1 21D61
    • macOS (desktop)                 • macos                     • darwin-arm64   • macOS 14.3.1 23D60 darwin-arm64
    • Mac Designed for iPad (desktop) • mac-designed-for-ipad     • darwin         • macOS 14.3.1 23D60 darwin-arm64
    • Chrome (web)                    • chrome                    • web-javascript • Google Chrome 128.0.6613.139

[✓] Network resources
    • All expected network resources are available.

Dart Version

3.5.2

Steps to Reproduce

偶发事件

Expected Result

预期应该是可以正常使用才对,因为大部用户都可以正常使用,只有机台windows设备,还有ios设备,macos设备无法请求网络

Actual Result

少部分 windows设备,还有ios设备,macos设备无法请求网络,出现DioExceptionType.unknown,这个如何解决呢?我的借口是https的

@xiongzhaoxu xiongzhaoxu added h: need triage This issue needs to be categorized s: bug Something isn't working labels Sep 23, 2024
@Johnjson
Copy link

I encountered the same problem with some iOS phones

@xiongzhaoxu
Copy link
Author

I encountered the same problem with some iOS phones

Have you found a solution yet

@Johnjson
Copy link

I encountered the same problem with some iOS phones

Have you found a solution yet

remain to be solved,My solution is for users to upgrade their phone system to the latest version

@xiongzhaoxu
Copy link
Author

I encountered the same problem with some iOS phones

Have you found a solution yet

remain to be solved,My solution is for users to upgrade their phone system to the latest version

Can upgrading the user's iOS system to the latest version solve this problem? We also have macOS and Windows users here who encounter this problem. Once it occurs, they cannot access any network

@Johnjson
Copy link

I encountered the same problem with some iOS phones

Have you found a solution yet

remain to be solved,My solution is for users to upgrade their phone system to the latest version

Can upgrading the user's iOS system to the latest version solve this problem? We also have macOS and Windows users here who encounter this problem. Once it occurs, they cannot access any network

The users I have encountered with problems are the older iOS version, such as the situation that the version has not been updated for several years, but some users are still unwilling to update the version, so this part of the use is still unable to use

@ChenTian-plaud
Copy link

same issue

@xiongzhaoxu
Copy link
Author

I found my problem. It was because I set options.headers['deviceName'] = "xxxx". This place should be encoded.
options.headers['deviceName'] =
Uri.encodeComponent(info["deviceName"]!); // Encode the device name to prevent non-ASCII characters

@ChenTian-plaud
Copy link

I found my problem. It was because I set options.headers['deviceName'] = "xxxx". This place should be encoded. options.headers['deviceName'] = Uri.encodeComponent(info["deviceName"]!); // Encode the device name to prevent non-ASCII characters

Thanks!I will try it

@AlexV525
Copy link
Member

AlexV525 commented Oct 1, 2024

抛出的异常里没有解释为什么异常?

@AlexV525 AlexV525 changed the title 我使用 dio: ^5.7.0,在ios,与 maocs 还以 windows上,某些设备会出现无法访问网络,会出现这个DioExceptionType.unknown,导致我的客户不能使用我的应用 Non-ASCII characters in headers might cause exceptions thrown with DioExceptionType.unknown Oct 1, 2024
@xiongzhaoxu
Copy link
Author

抛出的异常里没有解释为什么异常?

我当时并没有去注意这个异常,后面找了几个用不了的用户,专门来打印异常信息看到, 是因为他们是旧版本的ios系统,还有windows系统,他们可以设置中文的设备名称,而中文的信息传递到options.headers,就会报错“ Non-ASCII characters in headers might cause exceptions thrown with DioExceptionType.unknown”

@AlexV525 AlexV525 closed this as not planned Won't fix, can't repro, duplicate, stale Oct 1, 2024
@AlexV525 AlexV525 added i: not related and removed h: need triage This issue needs to be categorized s: bug Something isn't working labels Oct 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants