Giter Club home page Giter Club logo

baseokhttpv3's Introduction

Kongzue 的 Github

  

欢迎使用我分享的框架和代码。我的所有开源代码库都旨在减少重复性开发工作和不必要的麻烦,其性能不一定是最优的,但一定朝着对开发者最友好的方向进行设计,希望能多吸取建议和意见,与各位共同进步。

🚀统计

Kongzue's GitHub stats GitHub Streak

🛠️工具&语言

🌐我的个人网站和博客

个人网站

➡️kongzue.com

你可以访问这个网站来了解我做过哪些项目,以及当前在 Github 上开源的这些作品应用于了哪些已经上线的项目。

专栏博客

➡️Android开发中遇到的那些坑

小专栏,技术干货分享,包含应用层、硬件相关开发和网络相关开发中常见/非常见错误,排查办法及原因分析,以及一些基础介绍文章

➡️大话安卓

大话安卓群友文章分享,包含一些技术讨论、新框架介绍

📧如何与我取得联系

如果你对这些开源的框架有任何疑问或建议,可以直接在库的页面提交 issues,不过因为工作的原因我可能不能及时答复,你可以通过 Q 群:590498789,或者邮件至:[email protected],我会尽快答复。

baseokhttpv3's People

Contributors

kongzue avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

baseokhttpv3's Issues

HttpRequest url为null的逻辑判断有点问题

if (!url.startsWith("http")) { //如果url为null,这里就有问题,后面的isNull没起到该起的作用
            url = serviceUrl + url;
        }
        if (isNull(url)) {
            Log.e(">>>", "-------------------------------------");
            Log.e(">>>", "创建请求失败: 请求地址不能为空");
            Log.e(">>>", "=====================================");
        }

上传问题

我上传视频,还没上传完成就给我返回空了,但是视频仍然还在上传中,不知道怎么回事

https

如何进行https下载?比如github这种https的下载链接

文件上传 大小超过6m提示超时

V/ViewRootImpl: The specified message queue synchronization  barrier token has not been posted or has already been removed
D/OPDFontHInj: ViewRoot performTraversals. in com.ygink.cn/com.ygink.cn.activity.MainActivity
D/DecorView: onWindowFocusChangedFromViewRoot hasFocus: true, DecorView@e0d76b7[MainActivity]
D/OpenGLRenderer: endAllActiveAnimators on 0x7b7c881a00 (ListView) with handle 0x7b5fe73060
D/OnePlusJankManager:  Chor uploadMDM JANK_TYPE_ONCE mViewTitle = com.ygink.cn/com.ygink.cn.activity.MainActivity--- jank level = 1
D/DecorView: onWindowFocusChangedFromViewRoot hasFocus: true, DecorView@385931f[MainActivity]
V/ViewRootImpl: The specified message queue synchronization  barrier token has not been posted or has already been removed
D/OPDFontHInj: ViewRoot performTraversals. in Toast
V/ViewRootImpl: The specified message queue synchronization  barrier token has not been posted or has already been removed
D/OPDFontHInj: ViewRoot performTraversals. in com.ygink.cn/com.ygink.cn.activity.MainActivity
D/DecorView: onWindowFocusChangedFromViewRoot hasFocus: true, DecorView@df17295[MainActivity]
W/Choreographer: Already have a pending vsync event.  There should only be one at a time.
I/AssistStructure: Flattened final assist data: 11276 bytes, containing 2 windows, 87 views
I/>>>: addRequestInfo: RequestInfo{url='http://app.ygink.cn/api.php?app=10000&act=upload', parameter='archive_md5=4ov5m9uk9fu8ehmh6lbqrbj2lm&bz=5852555&cdname=kfkfkdkdkkdkdfk.wld&file=/storage/emulated/0/yyg/.tmp/wld/kfkfkdkdkkdkdfk.wld&t=1618764951477&token=fd50260c72dcd5098a7fdf4862232199&type=bak'}
I/>>>: 添加文件:file:kfkfkdkdkkdkdfk.wld
I/>>>: 添加请求头:
I/>>>>>>: Charset=UTF-8
I/>>>>>>: Referer=yyg
I/>>>: -------------------------------------
I/>>>: 创建请求:http://app.ygink.cn/api.php?app=10000&act=upload
I/>>>: 参数:
I/>>>>>>: archive_md5=4ov5m9uk9fu8ehmh6lbqrbj2lm&bz=5852555&cdname=kfkfkdkdkkdkdfk.wld&file=/storage/emulated/0/yyg/.tmp/wld/kfkfkdkdkkdkdfk.wld&t=1618764951477&token=fd50260c72dcd5098a7fdf4862232199&type=bak
I/>>>: 请求已发送 ->
D/OnePlusJankManager:  Chor uploadMDM JANK_TYPE_ONCE mViewTitle = com.ygink.cn/com.ygink.cn.activity.MainActivity--- jank level = 1
D/DecorView: onWindowFocusChangedFromViewRoot hasFocus: true, DecorView@385931f[MainActivity]
V/ViewRootImpl: The specified message queue synchronization  barrier token has not been posted or has already been removed
D/OPDFontHInj: ViewRoot performTraversals. in com.ygink.cn/com.ygink.cn.activity.MainActivity
D/DecorView: onWindowFocusChangedFromViewRoot hasFocus: true, DecorView@902e162[MainActivity]
E/>>>: 请求超时 ×
E/>>>: =====================================
D/DecorView: onWindowFocusChangedFromViewRoot hasFocus: true, DecorView@385931f[MainActivity]
V/ViewRootImpl: The specified message queue synchronization  barrier token has not been posted or has already been removed
D/OPDFontHInj: ViewRoot performTraversals. in Toast

文件POST上传

貌似好像不支持自定义文件后缀的上传,如.wld,上传报错空指针

websocket问题

你好,我这边没有做过websocket开发,看了下你的代码,问题1.服务器向客户端发消息 @OverRide
public void onMessage(String message) {
//处理收到的消息 message
resultWebsocket.setText("收到返回消息:" + message);
}
是调用这个方法收到消息对吧
问题2:那么客户端怎么向服务器发送消息呢?

关于文件上传,设置全局请求拦截

设置全局请求拦截后,根据业务需求,需要清除原数据,将原请求数据加密后请求,但是好像同时把文件上传的请求也清除了,导致上传文件后报错文件路径无效,不能够进行正常的文件上传

        BaseOkHttp.parameterInterceptListener = (ParameterInterceptListener<Parameter>) (context, url, parameter) -> {
            String data = parameter.toParameterString();
            parameter.clear();
            parameter.add("sign",SignData(data));
            parameter.add("data", RC4_jm(data));
            return parameter;
        };
                    File archive=new File(path);
                    String SignTime = Long.toString(System.currentTimeMillis());
                    WaitDialog.show((AppCompatActivity) requireActivity(), "请稍候...正在上传中..");
                    HttpRequest.build(requireActivity(), "api.php?app=10000&act=upload")
                            .addHeaders("Charset", "UTF-8")
                            .addParameter("type", "bak")
                            .addParameter("token", token)
                            .addParameter("cdname", name)
                            .addParameter("archive_md5",getFileMD5s(archive,32))
                            .addParameter("bz", inputStr)
                            .addParameter("file",archive)
                            .addParameter("t",SignTime)
                            .setJsonResponseListener(new JsonResponseListener() {
                                @Override
                                public void onResponse(JsonMap main, Exception error) {
                                    WaitDialog.dismiss();
                                    JsonMap msg = new JsonMap(RC4_jm2(main.getString("msg")));
                                    if (error == null) {
                                        if (main.getString("code").equals("200")){
                                            Toasty.success(requireContext(),"存档备份完成",Toasty.LENGTH_SHORT).show();
                                        }else {
                                            Toasty.info(requireContext(),msg.toString(),Toasty.LENGTH_SHORT).show();
                                        }
                                    } else {
                                        Toasty.error(requireContext(),"备份失败:"+error,Toasty.LENGTH_SHORT).show();
                                    }
                                }
                            })
                            .doPost();
                }

关于文件下载

那个我是用了系统时间命名的文件,为什么会只生成一个文件
下载第二个文件的时候名字还是第一个的,直接覆盖过去了

文件下载地址若失效,会走onDownloadSuccess回调

测试连接:https://down.wss.show/3dyl80b/9/0d/90do3dyl80b?cdn_sign=1660120096-5-0-bcca8f1d079bc819fefda02d5acb3d9f&exp=240&response-content-disposition=attachment%3B%20filename%3D%22%E6%B5%8B%E8%AF%95111_1.0.1.apk%22%3B%20filename%2A%3Dutf-8%27%27%25E6%25B5%258B%25E8%25AF%2595111_1.0.1.apk

http错误码为403,但是会走onDownloadSuccess()回调,可以修复下

代码如下:

HttpRequest.DOWNLOAD(
                    ActivityUtils.getTopActivity(), downloadUrl,
                    file,
                    new OnDownloadListener() {
                        @Override
                        public void onDownloadSuccess(File file) {
                            progressDialog.dismiss();
                            if (file.length() > 0) {
                                //下载完毕后安装apk文件
                                AppUtils.installApp(file);
                            } else {
                                ToastUtils.showShort("apk文件大小为0KB,更新失败!");
                            }
                        }

                        @Override
                        public void onDownloading(int progress) {
                            KLog.d("下载进度:" + progress);
                            //更新进度
                            progressDialog.setProgress(progress);
                        }

                        @Override
                        public void onDownloadFailed(Exception e) {
                            ToastUtils.showShort("下载失败,原因:" + e.getMessage());
                        }
                    }
            );

websocket

websocket 在需要给服务器传参数的情境下 不好用 disconnect 不管用 A页面传参数a,到b页面传了b 还打印的是a的数据

文件下载建议

希望支持全局Header请求头,build创建文件下载添加Header请求头无效

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.