{"id":21719725,"url":"https://github.com/troyzhxu/okhttps","last_synced_at":"2025-04-09T11:07:00.012Z","repository":{"id":37666968,"uuid":"251541844","full_name":"troyzhxu/okhttps","owner":"troyzhxu","description":"如艺术一般优雅，像 1、2、3 一样简单，前后端通用，轻量却强大的 HTTP 客户端（同时支持 WebSocket 与 Stomp 协议）","archived":false,"fork":false,"pushed_at":"2025-03-25T10:14:21.000Z","size":1724,"stargazers_count":504,"open_issues_count":12,"forks_count":76,"subscribers_count":11,"default_branch":"master","last_synced_at":"2025-04-02T10:08:24.661Z","etag":null,"topics":["android","download","download-manager","httputils","okhttp","okhttp3","okhttp3-util","okhttps-okhttp3","okhttputils","upload"],"latest_commit_sha":null,"homepage":"https://ok.zhxu.cn","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/troyzhxu.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-03-31T08:22:07.000Z","updated_at":"2025-04-01T03:46:10.000Z","dependencies_parsed_at":"2024-12-17T00:11:10.984Z","dependency_job_id":"f9a01b46-23b9-43fe-9ec1-735d96dc34ae","html_url":"https://github.com/troyzhxu/okhttps","commit_stats":null,"previous_names":["ejlchina/okhttps"],"tags_count":51,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/troyzhxu%2Fokhttps","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/troyzhxu%2Fokhttps/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/troyzhxu%2Fokhttps/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/troyzhxu%2Fokhttps/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/troyzhxu","download_url":"https://codeload.github.com/troyzhxu/okhttps/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248027407,"owners_count":21035594,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","download","download-manager","httputils","okhttp","okhttp3","okhttp3-util","okhttps-okhttp3","okhttputils","upload"],"created_at":"2024-11-26T01:41:53.957Z","updated_at":"2025-04-09T11:06:59.980Z","avatar_url":"https://github.com/troyzhxu.png","language":"Java","readme":"\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://ok.zhxu.cn/\" target=\"_blank\"\u003e\n    \u003cimg width=\"128\" src=\"https://images.gitee.com/uploads/images/2020/0511/091408_c26f1306_1393412.png\" alt=\"logo\"\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\u003cp align=\"center\"\u003e\n    \u003ca href=\"https://maven-badges.herokuapp.com/maven-central/cn.zhxu/okhttps/\"\u003e\u003cimg src=\"https://maven-badges.herokuapp.com/maven-central/cn.zhxu/okhttps/badge.svg\" alt=\"Maven Central\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://gitee.com/troyzhxu/okhttps/blob/master/LICENSE\"\u003e\u003cimg src=\"https://img.shields.io/hexpm/l/plug.svg\" alt=\"License\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://github.com/troyzhxu\"\u003e\u003cimg src=\"https://img.shields.io/badge/%E4%BD%9C%E8%80%85-troyzhxu-orange.svg\" alt=\"Troy.Zhou\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n## 文档\n\n网址：https://ok.zhxu.cn\n\n## 为什么用\n\n　　OkHttps 是近期开源的对 OkHttp3 轻量封装的框架，它独创的异步预处理器，特色的标签，灵活的上传下载进度监听与过程控制功能，在轻松解决很多问题的同时，设计上也力求纯粹与优雅。\n\n* 超级优雅的 API 设计，且链式调用，让你顺滑到底！\n* BaseURL、URL占位符、HTTP 同步 异步、WebSocket，让你想干啥就干啥！ \n* JSON、Xml 等自动封装与解析，且支持与任意格式的数据解析框架集成，想用啥就用啥！\n* 同步拦截器、异步预处理器、回调执行器、全局监听、回调阻断 等等，让你扩展无限功能！\n* 文件上传下载（过程控制、进度监听），上传下载如此简单！\n* 单方法回调，充分利用 Lambda 表达式，让你代码超级简洁！\n* 超级轻量，但性能卓越！\n\n* **阿里云最低 1 折**：https://www.aliyun.com/minisite/goods?userCode=zugtbi5w\n\n## 如何使用\n\n### 如艺术一般优雅，像 1、2、3 一样简单\n\n```java\n// 同步 HTTP\nList\u003cUser\u003e users = OkHttps.sync(\"/users\") \n        .get()                          // GET请求\n        .getBody()                      // 响应报文体\n        .toList(User.class);            // 自动反序列化 List \n\n// 异步 HTTP\nOkHttps.async(\"/users/1\")\n        .setOnResponse(res -\u003e {\n            // 自动反序列化 Bean \n            User user = res.getBody().toBean(User.class);\n        })\n        .get();                         // GET请求\n\n// WebSocket\nOkHttps.webSocket(\"/chat\") \n        .setOnMessage((WebSocket ws, Message msg) -\u003e {\n            // 从服务器接收消息\n            Chat chat = msg.toBean(Chat.class);\n            // 向服务器发送消息\n            ws.send(chat); \n        })\n        .listen();                     // 启动监听\n```\n\n### 请求三部曲\n\n#### 第一步、确定请求方式\n    \n* 同步 HTTP - `sync` 方法\n* 异步 HTTP - `async` 方法\n* WebSocket - `webSocket` 方法\n\n#### 第二步、构建请求任务\n\n* `addXxxPara` - 添加请求参数\n* `setOnXxxx` - 设置回调函数\n* `tag` - 添加标签\n* ...\n\n#### 第三步、调用请求方法\n\nHTTP 请求方法：\n\n* `get()` - GET 请求\n* `post()` - POST 请求\n* `put()` - PUT 请求\n* `delete()` - DELETE 请求\n* ...\n\nWebsocket 方法：\n\n* `listen()` - 启动监听\n\n#### 任意网络请求，都遵循请求三部曲！\n\n## 相关项目\n\n项目 | 最新版本 | 描述\n-|-|-\n[okhttps](https://gitee.com/troyzhxu/okhttps/tree/dev/okhttps) | 4.1.0 | OkHttps 核心模块\n[okhttps-fastjson](https://gitee.com/troyzhxu/okhttps/tree/dev/okhttps-fastjson) | 4.1.0 | 与 fastjson 集成\n[okhttps-fastjson](https://gitee.com/troyzhxu/okhttps/tree/dev/okhttps-fastjson2) | 4.1.0 | 与 fastjson2 集成\n[okhttps-fastjson](https://gitee.com/troyzhxu/okhttps/tree/dev/okhttps-fastjson2-jsonb) | 4.1.0 | 与 fastjson2-jsonb 集成\n[okhttps-gson](https://gitee.com/troyzhxu/okhttps/tree/dev/okhttps-gson) | 4.1.0 | 与 gson 集成\n[okhttps-jackson](https://gitee.com/troyzhxu/okhttps/tree/dev/okhttps-jackson) | 4.1.0 | 与 jackson 集成\n[okhttps-jackson](https://gitee.com/troyzhxu/okhttps/tree/dev/okhttps-jackson-xml) | 4.1.0 | 与 jackson-xml 集成\n[okhttps-jackson](https://gitee.com/troyzhxu/okhttps/tree/dev/okhttps-jackson-yaml) | 4.1.0 | 与 jackson-yaml 集成\n[okhttps-jackson](https://gitee.com/troyzhxu/okhttps/tree/dev/okhttps-snack3) | 4.1.0 | 与 jackson-yaml 集成\n[okhttps-stomp](https://gitee.com/troyzhxu/okhttps/tree/dev/okhttps-stomp) | 4.1.0 | 超级轻量的 Stomp 客户端\n[okhttps-xml](https://gitee.com/troyzhxu/okhttps/tree/dev/okhttps-xml) | 3.5.3 | XML 解析扩展\n\n## 超详细教程，请查看：https://ok.zhxu.cn\n\n## 联系方式\n\n* 微信：\u003cimg src=\"https://images.gitee.com/uploads/images/2020/0718/142637_87d27a5c_1393412.png\" width=\"700px\"\u003e\n* 由于近期交流群的二维码被爬，扫码入群方式已被关闭\n库的使用上若有疑问，可先加微信【18556739726】（请备注 OkHttps）再入群交流\n\n## 友情链接\n\n[**[ Bean Searcher ]** 比 MyBatis 效率快 100 倍的条件检索引擎，天生支持联表，使一行代码实现复杂列表检索成为可能！](https://github.com/ejlchina/bean-searcher)\n\n[**[ SA Token ]** 一个轻量级 Java 权限认证框架，让鉴权变得简单、优雅！](https://github.com/dromara/Sa-Token)\n\n[**[ hrun4j ]** 接口自动化测试解决方案 --工具选得好，下班回家早；测试用得对，半夜安心睡 ](https://github.com/lematechvip/hrun4j)\n\n[**[ Json Kit ]** 超轻量级 JSON 门面工具，用法简单，不依赖具体实现，让业务代码与 Jackson、Gson、Fastjson 等解耦！](https://gitee.com/troyzhxu/jsonkit)\n\n## 参与贡献\n\n1.  Fork 本仓库\n2.  新建 Feat_xxx 分支\n3.  提交代码\n4.  新建 Pull Request\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftroyzhxu%2Fokhttps","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftroyzhxu%2Fokhttps","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftroyzhxu%2Fokhttps/lists"}