{"id":13848602,"url":"https://github.com/litesuits/android-lite-http","last_synced_at":"2025-04-12T23:38:43.803Z","repository":{"id":14948821,"uuid":"17673470","full_name":"litesuits/android-lite-http","owner":"litesuits","description":"LiteHttp is a simple, intelligent and flexible HTTP framework for Android. With LiteHttp you can make HTTP request with only one line of code! It could convert a java model to the parameter and rander the response JSON as a java model intelligently.","archived":false,"fork":false,"pushed_at":"2017-05-17T03:17:54.000Z","size":10699,"stargazers_count":829,"open_issues_count":14,"forks_count":347,"subscribers_count":75,"default_branch":"master","last_synced_at":"2025-04-12T23:38:38.426Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://litesuits.com?form=ghttp","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"adobe-sign/AdobeSignJavaSdk","license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/litesuits.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGE-LOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-03-12T16:10:27.000Z","updated_at":"2025-03-03T03:04:25.000Z","dependencies_parsed_at":"2022-09-09T13:21:18.498Z","dependency_job_id":null,"html_url":"https://github.com/litesuits/android-lite-http","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/litesuits%2Fandroid-lite-http","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/litesuits%2Fandroid-lite-http/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/litesuits%2Fandroid-lite-http/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/litesuits%2Fandroid-lite-http/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/litesuits","download_url":"https://codeload.github.com/litesuits/android-lite-http/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248647255,"owners_count":21139081,"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":[],"created_at":"2024-08-04T19:00:53.771Z","updated_at":"2025-04-12T23:38:43.778Z","avatar_url":"https://github.com/litesuits.png","language":"Java","funding_links":[],"categories":["Index","Java","Libs","网络编程"],"sub_categories":["Networking","\u003cA NAME=\"Network\"\u003e\u003c/A\u003eNetwork"],"readme":"# Android network framework: LiteHttp\n\nTags : litehttp2.x-tutorials\n\n---\nWebsite : http://litesuits.com\n\nQQgroup : [42960650][1] , [47357508][2]\n\n[Android网络通信为啥子选 lite-http ？][3]\n\n[lite-http 初步使用 和 快速上手][4]\n\n---\n\n### 1. What‘s lite-http ? \n\n\u003e LiteHttp is a simple, intelligent and flexible HTTP framework for Android. With LiteHttp you can make HTTP request with only one line of code! \nIt could convert a java model to the parameter and rander the response JSON as a java model intelligently. \n\n\n### 2. Why choose lite-http ?\n\nSimple, powerful, make HTTP request with only one line of code:\n```Java\nUser user = liteHttp.get (url, User.class);\n```\n\nasynchronous download a file（execute on sub-thread，listen on ui-thread）:\n```java\nliteHttp.executeAsync(new FileRequest(url,path).setHttpListener(\n\tnew HttpListener\u003cFile\u003e(true, true, true) {\n\t\n        @Override\n        public void onLoading(AbstractRequest\u003cFile\u003e request, long total, long len) {\n            // loading notification\n        }\n\n        @Override\n        public void onSuccess(File file, Response\u003cFile\u003e response) {\n            // successfully download \n        }\n\t\t\n\t})\n);\n```\n\nconfigure an asynchronous login request by annotation:\n```java\nString loginUrl = \"http://litesuits.com/mockdata/user_get\";\n\n// 1. URL        : loginUrl\n// 2. Parameter  : name=value\u0026password= value\n// 3. Response   : User\n@HttpUri(loginUrl) \nclass LoginParam extends HttpRichParamModel\u003cUser\u003e {\n    private String name;\n    private String password;\n\n    public LoginParam(String name, String password) {\n        this.name = name;\n        this.password = password;\n    }\n}\nliteHttp.executeAsync(new LoginParam(\"lucy\", \"123456\"));\n```\nwill be built as **http://xxx?name=lucy\u0026password=123456**\n\nmore details, you can see lite-http introduction: [LiteHttp Introduction: Why should developers choose LiteHttp ? ][5]\n\n\n### 3. What are the fetures ?\n\n- Lightweight: tiny size overhead to your app. About 99kb for core jar. .\n\n- One-Thread-Based: all methods work on the same thread as the request was created.\n\n- Full support: GET, POST, PUT, DELETE, HEAD, TRACE, OPTIONS, PATCH.\n\n- Automatic: one line of code auto-complete translation between Model and Parameter, Json and Model.\n\n- Configurable: more flexible configuration options, up to 23+ items.\n\n- Polymorphic: more intuitive API, input and output is more clear.\n \n- Strong Concurrency: concurrent scheduler that comes with a strong, effective control of scheduling and queue control strategies.\n\n- Annotation Usage: convention over configuration. Parameters, Response, URL, Method, ID, TAG, etc. Can be configured.\n\n- Easy expansion: extend the abstract class DataParser to parse inputstream(network) to which you want..\n\n- Alternatively: interface-based, easy to replace the network connection implementations and Json serialization library.\n\n- Multilayer cache: hit Memory is more efficient! Multiple cache mode. Support for setting cache expire time.\n\n- Callback Flexible: callback can be on current or UI thread. listen the beginning, ending, success or failure, uploading, downloading, etc.\n\n- File Upload: support for single, multiple, large file uploads.\n\n- Downloads: support files, Bimtap download and progress notifications.\n\n- Network Disabled: disable one of a variety of network environments, such as specifying disabling 2G, 3G.\n\n- Statistics: time cost statistics and traffic statistics.\n\n- Exception system: a unified, concise, clear exception is thrown into three categories: client, network, server, and abnormalities can be accurately subdivided.\n\n- GZIP compression: automatic GZIP compression.\n\n- Automatic Retry: combined probe exception type and current network conditions, intelligent retry strategies.\n\n- Automatic redirection: based on the retry 30X state, and can set the maximum number of times to prevent excessive jump.\n\n\n### 4. Overall architecture of lite-http\n\n![Lite-http Chart][6]\n\nAbout App architecture, see my other article:\n[How to take high-quality Android project framework, the framework of the structure described in detail? ] [7]\n\n### 5. tutorials and analysis (◕‸◕)\n\nGood ◝‿◜, huh:\n\n [1. Initialization and preliminary usage] [8]\n\n [2. Simplified requests and non-safe method of use] [9]\n\n [3. Automatic model conversion] [10]\n\n [4. Custom DataParser and Json serialization library Replace] [11]\n\n [5. Files, bitmap upload and download] [12]\n\n [6. Disable network and traffic statistics] [13]\n\n [7. Retries and redirect] [14]\n\n [8. Exceptions handling and cancellation request] [15]\n\n [9. Multiple data transmission via POST(PUT)] [16]\n\n [10. Asynchronous concurrency and scheduling strategy] [17]\n\n [11. Global configuration and parameter settings Detailed] [18]\n\n [12. Annotation-Based request] [19]\n\n [13. Multilayer cache mechanism and usage] [20]\n\n [14. Detailed of callback listener] [21]\n\n [15. SmartExecutor： concurrent scheduler] [22]\n\n\n## LiteHttp： Android网络通信框架\n\n中文版 换个语种，再来一次\n\n标签： litehttp2.x版本系列教程\n\n---\n官网： http://litesuits.com\n\nQQ群： [大群 47357508][1] ， [二群 42960650][2]\n\n[Android网络框架为什么可以选用lite-http？][3]\n\n[lite-http 初步使用 和 快速起步上手][4]\n\n本系列文章面向android开发者，展示开源网络通信框架LiteHttp的主要用法，并讲解其关键功能的运作原理，同时传达了一些框架作者在日常开发中的一些最佳实践和经验。\n\n---\n\n# LiteHttp之开篇简介和大纲目录\n\n### 1. lite-http是什么？  (･̆⍛･̆)  \n\n\u003e LiteHttp是一款简单、智能、灵活的HTTP框架库，它在请求和响应层面做到了全自动构建和解析，主要用于Android快速开发。\n\n### 2. 为什么选lite-http？  (•́ ₃ •̀) \n\n简单、强大，线程无关，一行代码搞定API请求和数据转化：\n```java\nUser user = liteHttp.get(url, User.class);\n```\n\n当然也可以开启线程异步下载文件：\n```java\nliteHttp.executeAsync(new FileRequest(url,path).setHttpListener(\n\tnew HttpListener\u003cFile\u003e(true, true, true) {\n\t\n        @Override\n        public void onLoading(AbstractRequest\u003cFile\u003e request, long total, long len) {\n            // loading notification\n        }\n\n        @Override\n        public void onSuccess(File file, Response\u003cFile\u003e response) {\n            // successfully download \n        }\n\t\t\n\t})\n);\n```\n\n通过注解约定完成异步请求：\n```java\n@HttpUri(loginUrl) \nclass LoginParam extends HttpRichParamModel\u003cUser\u003e {\n    private String name;\n    private String password;\n\n    public LoginParam(String name, String password) {\n        this.name = name;\n        this.password = password;\n    }\n}\nliteHttp.executeAsync(new LoginParam(\"lucy\", \"123456\"));\n```\n将构建类似下面请求：http://xxx?name=lucy\u0026password=123456\n\n案例详情可见我另一篇lite-http引言文章：[LiteHttp 引言：开发者为什么要选LiteHttp？？][5]\n\n### 3. lite-http有什么特点？    (´ڡ`)  \n\n- 轻量级：微小的内存开销与Jar包体积，99K左右。\n\n- 单线程：请求本身具有线程无关特性，基于当前线程高效率运作。\n\n- 全支持：GET, POST, PUT, DELETE, HEAD, TRACE, OPTIONS, PATCH。\n\n- 全自动：一行代码自动完成Model与Parameter、Json与Model。\n\n- 可配置：更多更灵活的配置选择项，多达 23+ 项。\n\n- 多态化：更加直观的API，输入和输出更加明确。\n \n- 强并发：自带强大的并发调度器，有效控制任务调度与队列控制策略。\n\n- 注解化：通过注解约定参数，URL、Method、ID、TAG等都可约定。\n\n- 易拓展：自定义DataParser将网络数据流转化为你想要的数据类型。\n\n- 可替换：基于接口，轻松替换网络连接实现方式和Json序列化库。\n\n- 多层缓存：内存命中更高效！多种缓存模式，支持设置缓存有效期。\n\n- 回调灵活：可选择当前或UI线程执行回调，开始结束、成败、上传、下载进度等都可监听。\n\n- 文件上传：支持单个、多个大文件上传。\n\n- 文件下载：支持文件、Bimtap下载及其进度通知。\n\n- 网络禁用：快速禁用一种、多种网络环境，比如指定禁用 2G，3G 。\n\n- 数据统计：链接、读取时长统计，以及流量统计。\n\n- 异常体系：统一、简明、清晰地抛出三类异常：客户端、网络、服务器，且异常都可精确细分。\n\n- GZIP压缩：Request, Response 自动 GZIP 压缩节省流量。\n\n- 自动重试：结合探测异常类型和当前网络状况，智能执行重试策略。\n\n- 自动重定向：基于 30X 状态的重试，且可设置最大次数防止过度跳转。\n\n\n### 4. lite-http的整体架构是怎样的呀？    (´ڡ`)  \n\n![lite-http架构图][6]\n\n关于App架构，请看我另一篇文章分享：\n[怎样搭高质量的Android项目框架，框架的结构具体描述？][7]\n\n### 5. 老湿，来点教学和分析带我飞呗？    (◕‸◕)  \n\n好的 ◝‿◜ ，下面直接给你看，疗效好记得联系我，呵呵哒：\n\n [1. 初始化和初步使用][8]\n\n [2. 简化请求和非安全方法的使用][9]\n \n [3. 自动对象转化][10]\n \n [4. 自定义DataParser和Json序列化库的替换][11]\n \n [5. 文件、位图的上传和下载][12]\n \n [6. 禁用网络和流量、时间统计][13]\n \n [7. 重试和重定向][14]\n \n [8. 处理异常和取消请求][15]\n \n [9. POST方式的多种类型数据传输][16]\n \n [10. lite-http异步并发与调度策略][17]\n \n [11. 全局配置与参数设置详解][18]\n \n [12. 通过注解完成API请求][19]\n \n [13. 多层缓存机制及用法][20]\n \n [14. 回调监听器详解][21]\n \n [15. 并发调度控制器详解][22]\n\n\n  [1]: http://shang.qq.com/wpa/qunwpa?idkey=19bf15b9c85ec15c62141dd00618f725e2983803cd2b48566fa0e94964ae8370\n  [2]: http://shang.qq.com/wpa/qunwpa?idkey=492d63aaffb04b23d8dc4df21f6b594008cbe1a819978659cddab2dbc397684e\n  [3]: https://zybuluo.com/liter/note/186533\n  [4]: https://zybuluo.com/liter/note/186560\n  [5]: https://zybuluo.com/liter/note/186533\n  [6]: http://litesuits.com/imgs/lite-http-arch.png\n  [7]: https://zybuluo.com/liter/note/186526\n  [8]: https://zybuluo.com/liter/note/186560\n  [9]: https://zybuluo.com/liter/note/186561\n  [10]: https://zybuluo.com/liter/note/186565\n  [11]: https://zybuluo.com/liter/note/186583\n  [12]: https://zybuluo.com/liter/note/186756\n  [13]: https://zybuluo.com/liter/note/186801\n  [14]: https://zybuluo.com/liter/note/186860\n  [15]: https://zybuluo.com/liter/note/186900\n  [16]: https://zybuluo.com/liter/note/186965\n  [17]: https://zybuluo.com/liter/note/186998\n  [18]: https://zybuluo.com/liter/note/187016\n  [19]: https://zybuluo.com/liter/note/187568\n  [20]: https://zybuluo.com/liter/note/187894\n  [21]: https://zybuluo.com/liter/note/187904\n  [22]: https://zybuluo.com/liter/note/189537\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flitesuits%2Fandroid-lite-http","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flitesuits%2Fandroid-lite-http","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flitesuits%2Fandroid-lite-http/lists"}