登录 注册
开发者工具 androidgraalvmjavakotlin
47,112
Stars
9,287
Forks
1,629
Watchers
166
Open Issues
Apache-2.0
许可证
Kotlin
语言
2012-07-23
创建时间
2026-11-12
最近更新

项目能做什么

面向 JVM、Android 和 GraalVM 的精雕细琢的高性能 HTTP 客户端。
来源:基于仓库元数据 · 内容以仓库实际 README 为准

使用说明 查看原始 README 原仓库文档

中文使用说明暂未生成。下面保留原仓库 README 摘录,命令与配置均以原文为准。
原始 README 摘录(英文原文,节选前 3000 字符)
OkHttp
======

See the [project website][okhttp] for documentation and APIs.

HTTP is the way modern applications network. It’s how we exchange data & media. Doing HTTP
efficiently makes your stuff load faster and saves bandwidth.

OkHttp is an HTTP client that’s efficient by default:

 * HTTP/2 support allows all requests to the same host to share a socket.
 * Connection pooling reduces request latency (if HTTP/2 isn’t available).
 * Transparent GZIP shrinks download sizes.
 * Response caching avoids the network completely for repeat requests.

OkHttp perseveres when the network is troublesome: it will silently recover from common connection
problems. If your service has multiple IP addresses, OkHttp will attempt alternate addresses if the
first connect fails. This is necessary for IPv4+IPv6 and services hosted in redundant data
centers. OkHttp supports modern TLS features (TLS 1.3, ALPN, certificate pinning). It can be
configured to fall back for broad connectivity.

Using OkHttp is easy. Its request/response API is designed with fluent builders and immutability. It
supports both synchronous blocking calls and async calls with callbacks.

A well behaved user agent
-------------------------

OkHttp follows modern HTTP specifications such as

* HTTP Semantics - [RFC 9110](https://datatracker.ietf.org/doc/html/rfc9110)
* HTTP Caching- [RFC 9111](https://datatracker.ietf.org/doc/html/rfc9111)
* HTTP/1.1 - [RFC 9112](https://datatracker.ietf.org/doc/html/rfc9112)
* HTTP/2 - [RFC 9113](https://datatracker.ietf.org/doc/html/rfc9113)
* Websockets - [RFC 6455](https://datatracker.ietf.org/doc/html/rfc6455)
* SSE - [Server-sent events](https://html.spec.whatwg.org/multipage/server-sent-events.html#server-sent-events)

Where the spec is ambiguous, OkHttp follows modern user agents such as popular Browsers or common HTTP Libraries.

OkHttp is principled and avoids being overly configurable, especially when such configuration is
to workaround a buggy server, test invalid scenarios or that contradict the relevant RFC.
Other HTTP libraries exist that fill that gap allowing extensive customisation including potentially
invalid requests.

Example Limitations

* Does not allow GET with a body.
* Cache is not an interface with alternative implementations.

Get a URL
---------

This program downloads a URL and prints its contents as a string. [Full source][get_example].

```java
OkHttpClient client = new OkHttpClient();

String run(String url) throws IOException {
  Request request = new Request.Builder()
      .url(url)
      .build();

  try (Response response = client.newCall(request).execute()) {
    return response.body().string();
  }
}
```


Post to a Server
----------------

This program posts data to a service. [Full source][post_example].

```java
public static final MediaType JSON = MediaType.get("application/json");

OkHttpClient client = new OkHttpClient();

String post(String url, String json) throws IOException {
  RequestBody body = RequestBody.cre
阅读完整原文

商业机会分析 规则生成(AI 未配置)

综合评分 43.5 分。该项目在“个人可实施性”维度得 40 分,“付费可能性”维度得 20.0 分,差异化空间 70.0 分(评分依据见评分卡)。

面向细分需求的二次开发产品

产品构想基于 okhttp 的核心能力,聚焦一个更窄的场景(如某平台、某行业)做差异化。
目标用户该细分场景用户
难度/周期中 · 2~6 周
收费模式买断制 / 订阅制 / 广告
竞争风险细分需求规模需验证
依据 AI 推测:基于项目主题标签的判断
以上为规则引擎基于仓库公开数据生成的参考结论,包含推测成分,不构成投资或创业承诺;配置 AI 后可获得更深入的分析。
报告会保存到 个人中心

竞品与相似项目 GitHub Search 真实检索

项目中文简介Stars语言
jeasonlzy/okhttp-OkGo 中文介绍暂未生成
OkGo - 3.0 震撼来袭,该库是基于 Http 协议,封装了 OkHttp 的网络请求框架,比 Retrofit
10,542 Java
goldze/MVVMHabit 中文介绍暂未生成
👕基于谷歌最新AAC架构,MVVM设计模式的一套快速开发库,整合Okhttp+RxJava+Retrofit+Glide
7,694 Java
getActivity/AndroidProject 中文介绍暂未生成
Android 技术中台,但愿人长久,搬砖不再有
6,938 Java
hongyangAndroid/okhttputils 中文介绍暂未生成
[停止维护]okhttp的辅助类
6,822 Java
amitshekhariitbhu/Fast-Android-Networking 中文介绍暂未生成
🚀 A Complete Fast Android Networking Library that also suppo
5,933 Java
TommyLemon/Android-ZBLibrary 中文介绍暂未生成
🔥 Android MVP 快速开发框架,做国内 「示例最全面」「注释最详细」「使用最简单」「代码最严谨」的 Andro
5,604 Java
以上为通过 GitHub 官方 Search API 检索的相似项目,功能差异与优劣势需进一步人工确认,配置 AI 后可生成对比分析。

项目优势与风险

技术成熟度创建于 2012-07-23,近 30 天仍在推送
社区活跃Star 47,112 / Fork 9,287 / Issue 166(数据支持,可自行核实)
许可证Apache-2.0
主要风险上游项目方向可能变化;同赛道竞争者较多(见竞品表);热度与需求不完全等价

安装与使用

快速开始(以仓库 README 为准)
git clone https://github.com/lysine-dev/okhttp.git
cd okhttp
# 请阅读仓库 README 获取确切安装步骤(依赖、配置、启动命令)
阅读原仓库文档
术语说明:Docker=应用容器(把程序和依赖打包运行);API Key=调用外部服务的密钥;Git Clone=把仓库代码下载到本地。常见错误:API Key 未配置 / 端口占用 / 数据库连接失败,多数项目在 README 的 Troubleshooting 章节有说明。