[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-4307":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":10,"language":11,"languages":10,"totalLinesOfCode":10,"stars":12,"forks":13,"watchers":14,"openIssues":15,"contributorsCount":16,"subscribersCount":16,"size":16,"stars1d":16,"stars7d":17,"stars30d":18,"stars90d":16,"forks30d":16,"starsTrendScore":16,"compositeScore":19,"rankGlobal":10,"rankLanguage":10,"license":20,"archived":21,"fork":21,"defaultBranch":22,"hasWiki":23,"hasPages":23,"topics":24,"createdAt":10,"pushedAt":10,"updatedAt":31,"readmeContent":32,"aiSummary":33,"trendingCount":16,"starSnapshotCount":16,"syncStatus":17,"lastSyncTime":34,"discoverSource":35},4307,"async-http-client","AsyncHttpClient\u002Fasync-http-client","AsyncHttpClient","Asynchronous Http and WebSocket Client library for Java ","",null,"Java",6393,1591,346,93,0,2,4,40.61,"Other",false,"main",true,[25,26,27,28,29,30],"ahc","async","asynchttpclient","http-client","java","netty","2026-06-12 02:01:01","# Async Http Client\n\n[![Build](https:\u002F\u002Fgithub.com\u002FAsyncHttpClient\u002Fasync-http-client\u002Factions\u002Fworkflows\u002Fbuilds.yml\u002Fbadge.svg)](https:\u002F\u002Fgithub.com\u002FAsyncHttpClient\u002Fasync-http-client\u002Factions\u002Fworkflows\u002Fbuilds.yml)\n[![Maven Central](https:\u002F\u002Fimg.shields.io\u002Fmaven-central\u002Fv\u002Forg.asynchttpclient\u002Fasync-http-client)](https:\u002F\u002Fcentral.sonatype.com\u002Fartifact\u002Forg.asynchttpclient\u002Fasync-http-client)\n[![License](https:\u002F\u002Fimg.shields.io\u002Fgithub\u002Flicense\u002FAsyncHttpClient\u002Fasync-http-client)](https:\u002F\u002Fwww.apache.org\u002Flicenses\u002FLICENSE-2.0)\n\nAsyncHttpClient (AHC) is a high-performance, asynchronous HTTP client for Java\nbuilt on top of [Netty](https:\u002F\u002Fgithub.com\u002Fnetty\u002Fnetty).\nIt supports HTTP\u002F1.1, HTTP\u002F2, and WebSocket protocols.\n\n## Table of Contents\n\n- [Features](#features)\n- [Requirements](#requirements)\n- [Installation](#installation)\n- [Quick Start](#quick-start)\n- [Configuration](#configuration)\n- [HTTP Requests](#http-requests)\n- [Handling Responses](#handling-responses)\n- [HTTP\u002F2](#http2)\n- [WebSocket](#websocket)\n- [Authentication](#authentication)\n- [Proxy Support](#proxy-support)\n- [Community](#community)\n- [License](#license)\n\n## Features\n\n- **HTTP\u002F2 with multiplexing** — enabled by default over TLS via ALPN,\n  with connection multiplexing and GOAWAY handling\n- **HTTP\u002F1.1 and HTTP\u002F1.0** — connection pooling and keep-alive\n- **WebSocket** — text, binary, and ping\u002Fpong frame support\n- **Asynchronous API** — non-blocking I\u002FO with `ListenableFuture`\n  and `CompletableFuture`\n- **Compression** — automatic gzip, deflate, Brotli, and Zstd decompression\n- **Authentication** — Basic, Digest, NTLM, SPNEGO\u002FKerberos, and SCRAM-SHA-256\n- **Proxy** — HTTP, SOCKS4, and SOCKS5 with CONNECT tunneling\n- **Native transports** — optional Epoll, KQueue, and io_uring\n- **Request\u002Fresponse filters** — intercept and transform at each stage\n- **Cookie management** — RFC 6265-compliant cookie store\n- **Multipart uploads** — file, byte array, input stream, and string parts\n- **Resumable downloads** — built-in `ResumableIOExceptionFilter`\n\n## Requirements\n\nJava 11+\n\n## Installation\n\n**Maven:**\n\n```xml\n\u003Cdependency>\n    \u003CgroupId>org.asynchttpclient\u003C\u002FgroupId>\n    \u003CartifactId>async-http-client\u003C\u002FartifactId>\n    \u003Cversion>3.0.9\u003C\u002Fversion>\n\u003C\u002Fdependency>\n```\n\n**Gradle:**\n\n```groovy\nimplementation 'org.asynchttpclient:async-http-client:3.0.9'\n```\n\n\u003Cdetails>\n\u003Csummary>\u003Cb>Optional: Native Transport\u003C\u002Fb>\u003C\u002Fsummary>\n\nFor lower-latency I\u002FO on Linux, add a native transport dependency:\n\n```xml\n\u003C!-- Epoll (Linux) -->\n\u003Cdependency>\n    \u003CgroupId>io.netty\u003C\u002FgroupId>\n    \u003CartifactId>netty-transport-native-epoll\u003C\u002FartifactId>\n    \u003Cclassifier>linux-x86_64\u003C\u002Fclassifier>\n\u003C\u002Fdependency>\n\n\u003C!-- io_uring (Linux) -->\n\u003Cdependency>\n    \u003CgroupId>io.netty\u003C\u002FgroupId>\n    \u003CartifactId>netty-transport-native-io_uring\u003C\u002FartifactId>\n    \u003Cclassifier>linux-x86_64\u003C\u002Fclassifier>\n\u003C\u002Fdependency>\n```\n\nThen enable in config:\n\n```java\nAsyncHttpClient client = asyncHttpClient(config().setUseNativeTransport(true));\n```\n\n\u003C\u002Fdetails>\n\n\u003Cdetails>\n\u003Csummary>\u003Cb>Optional: Brotli \u002F Zstd Compression\u003C\u002Fb>\u003C\u002Fsummary>\n\n```xml\n\u003Cdependency>\n    \u003CgroupId>com.aayushatharva.brotli4j\u003C\u002FgroupId>\n    \u003CartifactId>brotli4j\u003C\u002FartifactId>\n    \u003Cversion>1.20.0\u003C\u002Fversion>\n\u003C\u002Fdependency>\n\n\u003Cdependency>\n    \u003CgroupId>com.github.luben\u003C\u002FgroupId>\n    \u003CartifactId>zstd-jni\u003C\u002FartifactId>\n    \u003Cversion>1.5.7-7\u003C\u002Fversion>\n\u003C\u002Fdependency>\n```\n\n\u003C\u002Fdetails>\n\n## Quick Start\n\nImport the DSL helpers:\n\n```java\nimport static org.asynchttpclient.Dsl.*;\n```\n\nCreate a client, execute a request, and read the response:\n\n```java\ntry (AsyncHttpClient client = asyncHttpClient()) {\n    \u002F\u002F Asynchronous\n    client.prepareGet(\"https:\u002F\u002Fwww.example.com\u002F\")\n        .execute()\n        .toCompletableFuture()\n        .thenApply(Response::getResponseBody)\n        .thenAccept(System.out::println)\n        .join();\n\n    \u002F\u002F Synchronous (blocking)\n    Response response = client.prepareGet(\"https:\u002F\u002Fwww.example.com\u002F\")\n        .execute()\n        .get();\n}\n```\n\n> **Note:** `AsyncHttpClient` instances are long-lived, shared resources.\n> Always close them when done. Creating a new client per request will degrade\n> performance due to repeated thread pool and connection pool creation.\n\n## Configuration\n\nUse `config()` to build an `AsyncHttpClientConfig`:\n\n```java\nAsyncHttpClient client = asyncHttpClient(config()\n    .setConnectTimeout(Duration.ofSeconds(5))\n    .setRequestTimeout(Duration.ofSeconds(30))\n    .setMaxConnections(500)\n    .setMaxConnectionsPerHost(100)\n    .setFollowRedirect(true)\n    .setMaxRedirects(5)\n    .setCompressionEnforced(true));\n```\n\n## HTTP Requests\n\n### Sending Requests\n\n**Bound** — build directly from the client:\n\n```java\nResponse response = client\n    .prepareGet(\"https:\u002F\u002Fapi.example.com\u002Fusers\")\n    .addHeader(\"Accept\", \"application\u002Fjson\")\n    .addQueryParam(\"page\", \"1\")\n    .execute()\n    .get();\n```\n\n**Unbound** — build standalone via DSL, then execute:\n\n```java\nRequest request = get(\"https:\u002F\u002Fapi.example.com\u002Fusers\")\n    .addHeader(\"Accept\", \"application\u002Fjson\")\n    .addQueryParam(\"page\", \"1\")\n    .build();\n\nResponse response = client.executeRequest(request).get();\n```\n\nMethods: `GET`, `POST`, `PUT`, `DELETE`, `PATCH`, `HEAD`, `OPTIONS`, `TRACE`.\n\n### Request Bodies\n\nUse `setBody` to attach a body. Supported types:\n\n| Type | Description |\n|---|---|\n| `String` | Text content |\n| `byte[]` | Raw bytes |\n| `ByteBuffer` | NIO buffer |\n| `InputStream` | Streaming input |\n| `File` | File content |\n| `Publisher\u003CByteBuf>` | Reactive stream |\n| `BodyGenerator` | Custom body generation |\n\n```java\nResponse response = client\n    .preparePost(\"https:\u002F\u002Fapi.example.com\u002Fdata\")\n    .setHeader(\"Content-Type\", \"application\u002Fjson\")\n    .setBody(\"{\\\"name\\\": \\\"value\\\"}\")\n    .execute()\n    .get();\n```\n\nFor streaming bodies, see `FeedableBodyGenerator` which lets you push chunks\nasynchronously.\n\n### Multipart Uploads\n\n```java\nResponse response = client\n    .preparePost(\"https:\u002F\u002Fapi.example.com\u002Fupload\")\n    .addBodyPart(new FilePart(\"file\", new File(\"report.pdf\"), \"application\u002Fpdf\"))\n    .addBodyPart(new StringPart(\"description\", \"Monthly report\"))\n    .execute()\n    .get();\n```\n\nPart types: `FilePart`, `ByteArrayPart`, `InputStreamPart`, `StringPart`.\n\n## Handling Responses\n\n### Blocking\n\n```java\nResponse response = client.prepareGet(\"https:\u002F\u002Fwww.example.com\u002F\").execute().get();\n```\n\n> Useful for debugging, but defeats the purpose of an async client in production.\n\n### ListenableFuture\n\n`execute()` returns a `ListenableFuture` that supports completion listeners:\n\n```java\nListenableFuture\u003CResponse> future = client\n    .prepareGet(\"https:\u002F\u002Fwww.example.com\u002F\")\n    .execute();\n\nfuture.addListener(() -> {\n    Response response = future.get();\n    System.out.println(response.getStatusCode());\n}, executor);\n```\n\n> If `executor` is `null`, the callback runs on the Netty I\u002FO thread.\n> **Never block** inside I\u002FO thread callbacks.\n\n### CompletableFuture\n\n```java\nclient.prepareGet(\"https:\u002F\u002Fwww.example.com\u002F\")\n    .execute()\n    .toCompletableFuture()\n    .thenApply(Response::getResponseBody)\n    .thenAccept(System.out::println)\n    .join();\n```\n\n### AsyncCompletionHandler\n\nFor most async use cases, extend `AsyncCompletionHandler` — it buffers the\nfull response and gives you a single `onCompleted(Response)` callback:\n\n```java\nclient.prepareGet(\"https:\u002F\u002Fwww.example.com\u002F\")\n    .execute(new AsyncCompletionHandler\u003CString>() {\n        @Override\n        public String onCompleted(Response response) {\n            return response.getResponseBody();\n        }\n    });\n```\n\n### AsyncHandler\n\nFor fine-grained control, implement `AsyncHandler` directly. This lets you\ninspect status, headers, and body chunks as they arrive and abort early:\n\n```java\nFuture\u003CInteger> future = client\n    .prepareGet(\"https:\u002F\u002Fwww.example.com\u002F\")\n    .execute(new AsyncHandler\u003C>() {\n        private int status;\n\n        @Override\n        public State onStatusReceived(HttpResponseStatus s) {\n            status = s.getStatusCode();\n            return State.CONTINUE;\n        }\n\n        @Override\n        public State onHeadersReceived(HttpHeaders headers) {\n            return State.CONTINUE;\n        }\n\n        @Override\n        public State onBodyPartReceived(HttpResponseBodyPart part) {\n            return State.ABORT; \u002F\u002F stop early — we only needed the status\n        }\n\n        @Override\n        public Integer onCompleted() {\n            return status;\n        }\n\n        @Override\n        public void onThrowable(Throwable t) {\n            t.printStackTrace();\n        }\n    });\n```\n\n## HTTP\u002F2\n\nHTTP\u002F2 is **enabled by default** for HTTPS connections via ALPN negotiation.\nThe client uses HTTP\u002F2 when the server supports it and falls back to HTTP\u002F1.1\notherwise. No additional configuration is required.\n\n- **Connection multiplexing** — concurrent streams over a single TCP connection\n- **GOAWAY handling** — graceful connection draining on server shutdown\n- **PING keepalive** — configurable ping frames to keep connections alive\n\n### HTTP\u002F2 Configuration\n\n```java\nAsyncHttpClient client = asyncHttpClient(config()\n    .setHttp2MaxConcurrentStreams(100)\n    .setHttp2InitialWindowSize(65_535)\n    .setHttp2MaxFrameSize(16_384)\n    .setHttp2MaxHeaderListSize(8_192)\n    .setHttp2PingInterval(Duration.ofSeconds(30))  \u002F\u002F keepalive pings\n    .setHttp2CleartextEnabled(true));               \u002F\u002F h2c prior knowledge\n```\n\nTo force HTTP\u002F1.1, disable HTTP\u002F2:\n\n```java\nAsyncHttpClient client = asyncHttpClient(config().setHttp2Enabled(false));\n```\n\n## WebSocket\n\n```java\nWebSocket ws = client\n    .prepareGet(\"wss:\u002F\u002Fecho.example.com\u002F\")\n    .execute(new WebSocketUpgradeHandler.Builder()\n        .addWebSocketListener(new WebSocketListener() {\n            @Override\n            public void onOpen(WebSocket ws) {\n                ws.sendTextFrame(\"Hello!\");\n            }\n\n            @Override\n            public void onTextFrame(String payload, boolean finalFragment, int rsv) {\n                System.out.println(payload);\n            }\n\n            @Override\n            public void onClose(WebSocket ws, int code, String reason) {}\n\n            @Override\n            public void onError(Throwable t) { t.printStackTrace(); }\n        })\n        .build())\n    .get();\n```\n\n## Authentication\n\n```java\n\u002F\u002F Client-wide Basic auth\nAsyncHttpClient client = asyncHttpClient(config()\n    .setRealm(basicAuthRealm(\"user\", \"password\")));\n\n\u002F\u002F Per-request Digest auth\nResponse response = client\n    .prepareGet(\"https:\u002F\u002Fapi.example.com\u002Fprotected\")\n    .setRealm(digestAuthRealm(\"user\", \"password\").build())\n    .execute()\n    .get();\n\n\u002F\u002F SCRAM-SHA-256 (RFC 7804)\nResponse response = client\n    .prepareGet(\"https:\u002F\u002Fapi.example.com\u002Fprotected\")\n    .setRealm(scramSha256AuthRealm(\"user\", \"password\").build())\n    .execute()\n    .get();\n```\n\nSupported schemes: **Basic**, **Digest**, **NTLM**, **SPNEGO\u002FKerberos**, **SCRAM-SHA-256**.\n\n## Proxy Support\n\n```java\n\u002F\u002F HTTP proxy\nAsyncHttpClient client = asyncHttpClient(config()\n    .setProxyServer(proxyServer(\"proxy.example.com\", 8080)));\n\n\u002F\u002F Authenticated proxy\nAsyncHttpClient client = asyncHttpClient(config()\n    .setProxyServer(proxyServer(\"proxy.example.com\", 8080)\n        .setRealm(basicAuthRealm(\"proxyUser\", \"proxyPassword\"))));\n```\n\nSOCKS4 and SOCKS5 proxies are also supported.\n\n## Community\n\n- [GitHub Discussions](https:\u002F\u002Fgithub.com\u002FAsyncHttpClient\u002Fasync-http-client\u002Fdiscussions) — questions, ideas, and general discussion\n- [Issue Tracker](https:\u002F\u002Fgithub.com\u002FAsyncHttpClient\u002Fasync-http-client\u002Fissues) — bug reports and feature requests\n\n## License\n\n[Apache License 2.0](LICENSE.txt)\n","AsyncHttpClient (AHC) 是一个高性能的异步HTTP和WebSocket客户端库，专为Java设计。它基于Netty构建，支持HTTP\u002F1.1、HTTP\u002F2和WebSocket协议，具备多路复用、连接池、自动压缩、多种认证方式及代理支持等核心功能。AHC采用非阻塞I\u002FO模型，提供`ListenableFuture`和`CompletableFuture`接口，适用于需要高并发处理能力的应用场景，如大规模数据抓取、实时通信服务等。此外，它还支持可选的本地传输（如Epoll、KQueue）以进一步优化性能。","2026-06-11 02:59:33","top_language"]