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

[Bug report] ExtendedNetworkImageProvider的headers bug #597

Closed
popsams opened this issue Jul 13, 2023 · 7 comments
Closed

[Bug report] ExtendedNetworkImageProvider的headers bug #597

popsams opened this issue Jul 13, 2023 · 7 comments

Comments

@popsams
Copy link

popsams commented Jul 13, 2023

Version

8.0.2

Platforms

dart, Android

Device Model

Galaxy S23

flutter info

[flutter] flutter doctor -v
Flutter assets will be downloaded from https://storage.flutter-io.cn. Make sure you trust this source!
[√] Flutter (Channel stable, 3.10.5, on Microsoft Windows [版本 10.0.22621.1928], locale zh-CN)
    • Flutter version 3.10.5 on channel stable at D:\Code\flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 796c8ef792 (4 weeks ago), 2023-06-13 15:51:02 -0700
    • Engine revision 45f6e00911
    • Dart version 3.0.5
    • DevTools version 2.23.1
    • Pub download mirror https://pub.flutter-io.cn
    • Flutter download mirror https://storage.flutter-io.cn

[√] Windows Version (Installed version of Windows is version 10 or higher)

[√] Android toolchain - develop for Android devices (Android SDK version 33.0.2)
    • Android SDK at D:\Android\Android-Sdk
    • Platform android-33-2, build-tools 33.0.2
    • ANDROID_HOME = D:\Android\Android-Sdk
    • ANDROID_SDK_ROOT = D:\Android\Android-Sdk
    • Java binary at: C:\Program Files\Java\jdk-11\bin\java
    • Java version Java(TM) SE Runtime Environment 18.9 (build 11+28)
    • All Android licenses accepted.

[√] Chrome - develop for the web
    • Chrome at C:\Program Files (x86)\Google\Chrome\Application\chrome.exe

[√] Visual Studio - develop for Windows (Visual Studio Enterprise 2022 17.6.4)
    • Visual Studio at C:\Program Files\Microsoft Visual Studio\2022\Enterprise
    • Visual Studio Enterprise 2022 version 17.6.33815.320
    • Windows 10 SDK version 10.0.20348.0

[√] Android Studio (version 2022.2)
    • Android Studio at D:\Android\Android Studio
    • 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-b2043.56-9586694)

[√] VS Code (version 1.80.0)
    • VS Code at C:\Users\stan\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension version 3.68.0

[√] Connected device (4 available)
    • Subsystem for Android TM (mobile) • 127.0.0.1:58526 • android-x64    • Android 12 (API 32)
    • Windows (desktop)                 • windows         • windows-x64    • Microsoft Windows [版本 10.0.22621.1928]
    • Chrome (web)                      • chrome          • web-javascript • Google Chrome 114.0.5735.199
    • Edge (web)                        • edge            • web-javascript • Microsoft Edge 114.0.1823.67

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

• No issues found!
exit code 0

How to reproduce?

ExtendedNetworkImageProvider的headers默认会把 “Dart3.0” 加到user-agent里面了,导致有些图片来源检测到了是dart的user-agent,直接返回forbidden了,辛苦作者可以优化一下吗,headers传的是什么就是什么,别默认加入其他的默认内容,感谢了

The headers of ExtendedNetworkImageProvider default to adding "Dart3.0" to the user agent, resulting in some image sources detecting it as Dart's user agent and returning it directly to Forbidden. Can the author optimize it? The headers are what they pass, so don't add other default content by default. Thank you

Logs

No response

Example code (optional)

No response

Contact

No response

@popsams popsams changed the title [Bug report] [Bug report] ExtendedNetworkImageProvider的headers bug Jul 13, 2023
@zmtzawqlp
Copy link
Member

这是官方的逻辑吧。你先给官方提issue

@popsams
Copy link
Author

popsams commented Jul 14, 2023

好的

@popsams
Copy link
Author

popsams commented Jul 18, 2023

这是官方的逻辑吧。你先给官方提issue

官方给了这个方案,意思就是在使用HttpClient的时候,自己自定义覆盖掉默认的ua,所以请大佬看下,估计还得您那里稍微修改下使用HttpClient的逻辑,自定义覆盖掉ua,根据用户传什么就是什么,不默认加其他内容

dart-lang/http#990 (comment)

@zmtzawqlp
Copy link
Member

zmtzawqlp commented Jul 18, 2023

@popsams
Copy link
Author

popsams commented Jul 18, 2023

https://github.com/fluttercandies/extended_image_library/blob/dcc13d12d4b77687cc2aa4e888a8754e298c9fe1/lib/src/network/network_image_io.dart#L374

自己设置一下

大佬,您说自己设置一下的意思是我这边拉项目代码改好了提交,还是说我把源码加入项目里单独修改自己用就行,自己修改后面不能和你这边同步更新了

按照官方意思把 HttpClient 的 userAgent 设置空就行,您可以改一下吗,就一行代码

@zmtzawqlp
Copy link
Member

这是一个静态属性呢。。你拿到自己设置下 ua 不就好了

@popsams
Copy link
Author

popsams commented Jul 18, 2023

这是一个静态属性呢。。你拿到自己设置下 ua 不就好了

好的

@popsams popsams closed this as completed Jul 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants