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

下载链接重定向的问题 #11

Closed
REBOOTERS opened this issue Nov 23, 2020 · 3 comments
Closed

下载链接重定向的问题 #11

REBOOTERS opened this issue Nov 23, 2020 · 3 comments

Comments

@REBOOTERS
Copy link

REBOOTERS commented Nov 23, 2020

DownApkRunnable 中使用 HttpURLConnection 进行网络请求,没有处理下载链接存在重定向的情况(很多时候会根据下载地址重定向到一个 CDN 的地址)。这个时候返回的 response 并不是一个实际的 apk 流,而是一次重定向的内容,建议对 resonse code 做一次判断,类似下面这种

            val conn = connectionUrl.openConnection() as HttpURLConnection
            conn.connect()

            if (conn.responseCode == 302) {
                val redirectUrl = conn.getHeaderField("Location")
           。。。。。
          }

或者使用 OkHttp 进行网络请求的处理,其内部会自动完成上述过程。

@AnyLifeZLB
Copy link
Owner

AnyLifeZLB commented Dec 2, 2020

好的,有没有这种重定向地址,我处理一下 @REBOOTERS

@REBOOTERS
Copy link
Author

好的,有没有这种重定向地址,我处理一下 @REBOOTERS

https://api.developer.xiaomi.com/autoupdate/updateself/download/fc6b8eba5351dedf2a79dab71c9bb299edcd1fb85AppStore_06af5546730ca4df0191ab263a2ae82b/com.engineer.map_1038.apk

@AnyLifeZLB
Copy link
Owner

1.1.4 版本已经解决此问题

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