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

关于加密post请求查询新版本问题 #24

Closed
sweet2o09 opened this issue May 2, 2017 · 4 comments
Closed

关于加密post请求查询新版本问题 #24

sweet2o09 opened this issue May 2, 2017 · 4 comments

Comments

@sweet2o09
Copy link

你好,看了很多个自升级库,感觉你的这个是比较好的,不过有个问题想问下
我这边的App,查询版本更新是使用post方式向服务器传递当前版本号等参数,并且加密过后传递给服务器,服务器会根据我传递的版本号,告知我是否有新版本
但是如果我要使用你的这个库,不知道如何处理这个请求,是否可以把请求回来的参数直接传递到你的这个update库中,剩下的下载,通知栏,安装等操作由你的库来控制?

@czy1121
Copy link
Owner

czy1121 commented May 2, 2017

呃,暂时post只能重写IUpdateChecker
参考:

UpdateManager.create(this).setUrl(mCheckUrl).setChecker(new IUpdateChecker() {
    @Override
    public void check(ICheckAgent agent, String url) {
        HttpURLConnection connection = null;
        try {
            connection = (HttpURLConnection) new URL(url).openConnection();
            connection.setRequestProperty("Accept", "application/json");
            connection.connect();
            if (connection.getResponseCode() == HttpURLConnection.HTTP_OK) {
                agent.setInfo(UpdateUtil.readString(connection.getInputStream()));
            } else {
                agent.setError(new UpdateError(UpdateError.CHECK_HTTP_STATUS, "" + connection.getResponseCode()));
            }
        } catch (IOException e) {
            e.printStackTrace();
            agent.setError(new UpdateError(UpdateError.CHECK_NETWORK_IO));
        } finally {
            if (connection != null) {
                connection.disconnect();
            }
        }
    }
}).check();

@ljackChen001
Copy link

你解决了嘛?用后台是post+token请求 不知道咋整了

@czy1121
Copy link
Owner

czy1121 commented May 3, 2017

@sweet2o09 @ljackChen001 已更新1.1.1版支持POST请求

setPostData(@NonNull byte[] data);
setPostData(@NonNull String data);

UpdateManager.create(this).setUrl(mCheckUrl).setPostData("param=abc&param2=xyz").check();

@sweet2o09
Copy link
Author

恩,这样就更灵活了,我可以用自己的网络框架请求数据,然后把数据传递给你的这个库,实现下载功能...谢谢

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

3 participants