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

下载时使用的Headers设置UA有误,会被拦截 #4

Closed
yllhwa opened this issue May 21, 2022 · 2 comments
Closed

下载时使用的Headers设置UA有误,会被拦截 #4

yllhwa opened this issue May 21, 2022 · 2 comments

Comments

@yllhwa
Copy link
Contributor

yllhwa commented May 21, 2022

Headers.Builder downloadHeadersBuilder = new Headers.Builder()
.add("accept", "*/*")
.add("accept-encoding", "gzip, deflate, br")
.add("Accept-Language", "zh-CN,zh-Hans;q=0.9")
.add("Connection", "keep-alive")
.add("Origin", "https://m.bilibili.com")
.add("Referer", "https://m.bilibili.com/")
.add("user-agent", Bili.UA);

此处downloadHeaders使用小写的user-agent是有什么特殊考虑吗?
经测试若使用小写的user-agent,系统(MIUI13)会设置大写的User-Agent:AndroidDownloadManager/12 (Linux; U; Android 12; M2007J3SC Build/SKQ1.211006.001),从而会被b站拦截(403 Forbidden)无法下载。
修改为大写后功能恢复正常。
顺便感谢开发该工具!

@KafuuNeko
Copy link
Owner

您好,感谢反馈问题。
这里是小写是因为当时我抓包时使用的浏览器是edge,此浏览器的开发者工具中是小写显示的,因此我在拷贝到代码的UA请求头域是小写的。
关于MIUI13的问题,可能是因为MIUI13的DownloadManager在检测某请求头域是否存在时是大小写敏感的,全小写的请求头域可能被判定为不存在而自动添加了DownloadManager的UA。因此在下版本中所有请求头域都将改为默认首字母大写以避免此类问题。

KafuuNeko added a commit that referenced this issue May 22, 2022
优化个人界面布局
支持屏幕翻转
优化视频封装格式转换与音频提取
解决’下载时使用的Headers设置UA有误,会被拦截 #4
KafuuNeko added a commit that referenced this issue May 22, 2022
1. 优化个人界面布局
2. 支持屏幕翻转
3. 优化视频封装格式转换与音频提取
4. 解决’下载时使用的Headers设置UA有误,会被拦截 #4
5. 修复快速点击的情况下重复打开窗口
6. 修复部分视频无法下载
7. 登录页支持手动输入cookies #3
@yllhwa yllhwa closed this as completed Sep 21, 2022
@yllhwa
Copy link
Contributor Author

yllhwa commented Sep 21, 2022

忘记close了233
已经用了几个月了,确实好用♥

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