{"id":33179339,"url":"https://github.com/king/king-http-client","last_synced_at":"2026-01-26T04:10:46.698Z","repository":{"id":1901274,"uuid":"44750616","full_name":"king/king-http-client","owner":"king","description":"An asynchronous http client with support for sse","archived":false,"fork":false,"pushed_at":"2024-02-20T13:42:27.000Z","size":1004,"stargazers_count":27,"open_issues_count":1,"forks_count":19,"subscribers_count":17,"default_branch":"master","last_synced_at":"2024-03-26T05:00:38.718Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/king.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE-APACHE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":"AUTHORS","dei":null}},"created_at":"2015-10-22T14:26:37.000Z","updated_at":"2024-02-20T14:38:28.000Z","dependencies_parsed_at":"2024-01-29T13:26:24.971Z","dependency_job_id":"e1850354-2edd-4f0c-a73c-18938bb78ac9","html_url":"https://github.com/king/king-http-client","commit_stats":null,"previous_names":[],"tags_count":28,"template":false,"template_full_name":null,"purl":"pkg:github/king/king-http-client","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/king%2Fking-http-client","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/king%2Fking-http-client/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/king%2Fking-http-client/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/king%2Fking-http-client/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/king","download_url":"https://codeload.github.com/king/king-http-client/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/king%2Fking-http-client/sbom","scorecard":{"id":560670,"data":{"date":"2025-08-11","repo":{"name":"github.com/king/king-http-client","commit":"e74cd9ec20a1c3a6f34222bf951864fbf16c35d5"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":4.7,"checks":[{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Code-Review","score":1,"reason":"Found 4/25 approved changesets -- score normalized to 1","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Token-Permissions","score":9,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Info: jobLevel 'actions' permission set to 'read': .github/workflows/codeql-analysis.yml:28","Info: jobLevel 'contents' permission set to 'read': .github/workflows/codeql-analysis.yml:29","Warn: no topLevel permission defined: .github/workflows/codeql-analysis.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Binary-Artifacts","score":9,"reason":"binaries present in source code","details":["Warn: binary detected: gradle/wrapper/gradle-wrapper.jar:1"],"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/codeql-analysis.yml:42: update your workflow using https://app.stepsecurity.io/secureworkflow/king/king-http-client/codeql-analysis.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/codeql-analysis.yml:46: update your workflow using https://app.stepsecurity.io/secureworkflow/king/king-http-client/codeql-analysis.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/codeql-analysis.yml:57: update your workflow using https://app.stepsecurity.io/secureworkflow/king/king-http-client/codeql-analysis.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/codeql-analysis.yml:71: update your workflow using https://app.stepsecurity.io/secureworkflow/king/king-http-client/codeql-analysis.yml/master?enable=pin","Info:   0 out of   4 GitHub-owned GitHubAction dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"License","score":9,"reason":"license file detected","details":["Info: project has a license file: LICENSE-APACHE:0","Warn: project license file does not contain an FSF or OSI license."],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":7,"reason":"SAST tool detected but not run on all commits","details":["Info: SAST configuration detected: CodeQL","Warn: 0 commits out of 12 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-20T13:34:39.556Z","repository_id":1901274,"created_at":"2025-08-20T13:34:39.556Z","updated_at":"2025-08-20T13:34:39.556Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28766535,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-26T03:54:34.369Z","status":"ssl_error","status_checked_at":"2026-01-26T03:54:33.031Z","response_time":59,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":"2025-11-16T03:00:36.829Z","updated_at":"2026-01-26T04:10:46.692Z","avatar_url":"https://github.com/king.png","language":"Java","funding_links":[],"categories":["网络编程"],"sub_categories":[],"readme":"# king-http-client\n## 'com.king.king-http-client:king-http-client:3.0.21'\n[![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.king.king-http-client/king-http-client/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.king.king-http-client/king-http-client)\n\n## New in version 3.0.21\n* Fixed a bug that could lead to a memory leak \n* Added new api for websocket where sending frames and sending messages are separated\n\n## New in version 3.0.20\n * Made it possible to specify a custom dns resolver using ConfKeys.\n \n## New in version 3.0.19\n* Minor bugfixes\n\n## New in version 3.0.18\n* Fixed a bug related to returned content-type containing quoted charset\n\n## New in version 3.0.17\n* Fixed bug related to hostnames that contained \"-\" and \"_\".\n\n## New in Version 3.0.16\n* Adding support for sending manual pong frames in websocket connections\n\n## New in Version 3.0.15\n* Made HttpClient.create(HttpMethod httpMethod, String uri) return HttpClientRequestWithBodyBuilder\n\n## New in Version 3.0.14\n* Fixed bug in ChannelManager which caused compression failures\n* Improved WebSocket client, added support for automatically splitting too large frames\n* Improved WebSocket client, added more configuration options to both builder as well as default values. \n\n## New in Version 3.0.13\n* Extracted interfaces for Header values\n\n## New in Version 3.0.12\n* Added support for disabling / enabling automatic decompression of gziped response bodies. This can either be configured globaly through `ConfKeys.AUTOMATICALLY_DECOMPRESS_RESPONSE` or per request through `.automaticallyDecompressResponse(boolean)`.\n\n## New in Version 3.0.11\n* Added checks for bad servers sending invalid http responses\n* Fixed issue where HEAD requests completed twice\n\n## New in Version 3.0.10\n* Made it possible to close an `WebSocketConnection`\n\n## New in Version 3.0.9\n* Bug fix for an race condition in WebSocket connection. Now onConnected callback is called before the CompletableFuture is completed. Both the onConnected and CompletableFuture is called on the netto io threads, so avoid blocking!\n\n## New in Version 3.0.8\n* Added support for fetching http version as well as status reason from `HttpResponse`\n* Added support for supplying what http verb should be used in HttpClient\n\n## New in Version 3.0.7\n* Bumped netty version to 4.1.29.Final\n\n## New in Version 3.0.6\n* Improved shutdown by waiting for all channels to close\n* Fixed potential NPE\n* Removed duplicate AttributeKey\n* Added `HttpClient.isStarted()` method\n\n## New in Version 3.0.5\n* Fixed port parsing issue for WSS\n\n## New in Version 3.0.4\n* Correctly release retained frames in WS\n\n## New in Version 3.0.2\n* Added support for handling http redirects for websocket connections.\n\n## New in Version 3.0.1\n* Fixed a critical memmory leak in 3.0.0\n\n## New in Version 3.0.0\n* Redesign of builder APIs.\n  * The `ResponseBodyConsumer` have been moved from the  `execute` method to the `build` method.\n  * The `HttpCallback` have been moved from the  `execute` method to the `withHttpCallback` method.\n  * The `NioCallback` have been moved from the  `execute` method to the `withNioCallback` method.\n  * A few methods have been renamed to align them between the classes.\n* Added support for websocket.\n* Added support for building multipart uploads.\n* Added support for upload progression callbacks through the `withUploadCallback` method.\n* Fixed a bug in idle timeout handling.\n\n## New in Version 2.3.1\n* Client is now waiting for ssl/tls handshake to complete before trying to push data\n\n## New in Version 2.3.0 \n* Changed to Java 8\n* `Future\u003cFutureResult\u003cT\u003e\u003e` has been replaced with `CompletableFuture\u003cHttpResponse\u003cT\u003e\u003e` in `BuiltClientRequest`.\n* The `CompletableFuture.get()` can now throw `ExecutionException` which contains the underlaying Exception (Before this exception could be fetched from the `FutureResult`).\n* `HttpClient.setConf` has been deprecated and replaced with `NettyHttpClientBuilder.setOption`\n* `UriQueryBuilder.addParameter` can now be chained.\n* Netty 4.1 has been bumped to 4.1.15.Final.\n\n## New in Version 2.2.0\n* Improved SseClient\n\n## New in Version 2.1.0\n * Upgraded to use Netty-4.1\n \n## New in Version 2.0.0\n * Supports Server Side Events.\n * Support for enabling epoll (set ConfKeys.EPOLL to true)\n\n\n## Api\n\nFirst off the HttpClient needs to be created and started.\nTo make it easier, use the NettyHttpClientBuilder.\nUse the different set methods on the NettyHttpClientBuilder to tweak how HttpClient works.\n\n```java\nNettyHttpClientBuilder nettyHttpClientBuilder = new NettyHttpClientBuilder();\nHttpClient httpClient = nettyHttpClientBuilder.createHttpClient();\nhttpClient.start();\n```\n\nBefore start is called, httpClient.setConf can be used to tweak internal settings of the client.\n\nThen to use it, use the fluent method builder on the HttpClient:\n\n```java\nCompletableFuture\u003cHttpResponse\u003cString\u003e\u003e future = httpClient.createGet(\"http://some.url\").build().execute();\n\nCompletableFuture\u003cHttpResponse\u003cbyte[]\u003e\u003e byteResponseFuture = httpClient.createPost(\"http://someUrl\")\n\t\t\t.content(\"someContentToBePosted\".getBytes())\n\t\t\t.addQueryParameter(\"param1\", \"value1\")\n\t\t\t.addHeader(\"header1\", \"headerValue1\")\n\t\t\t.build(ByteArrayResponseBodyConsumer::new)\n\t\t\t.execute();\n```\n\nOr using callback objects:\n\n```java\nhttpClient.createGet(\"http://some.url\").build().withHttpCallback(new HttpCallback\u003cString\u003e() {\n\t\t\t@Override\n\t\t\tpublic void onCompleted(HttpResponse\u003cString\u003e httpResponse) {\n\n\t\t\t}\n\n\t\t\t@Override\n\t\t\tpublic void onError(Throwable throwable) {\n\n\t\t\t}\n\t\t}).execute();\n```\n\n\nFor more complex cases or when the result is unfit to handle as a string, a ResponseBodyConsumer can be defined on the first build method:\n\n```java\nhttpClient.createGet(\"http://some.url\").build(() -\u003e new ResponseBodyConsumer\u003cSomeObject\u003e() {\n\t@Override\n\tpublic void onBodyStart(String contentType, String charset, long contentLength) throws Exception {\n\n\t}\n\n\t@Override\n\tpublic void onReceivedContentPart(ByteBuffer buffer) throws Exception {\n\t\t//aggregate the content from the server\n\t}\n\n\t@Override\n\tpublic void onCompletedBody() throws Exception {\n\t\t//build the SomeObject from the aggregated data\n\t}\n\n\t@Override\n\tpublic SomeObject getBody() {\n\t\treturn null;\n\t}\n}).withHttpCallback(new HttpCallback\u003cSomeObject\u003e() {\n\t@Override\n\tpublic void onCompleted(HttpResponse\u003cSomeObject\u003e httpResponse) {\n\n\t}\n\n\t@Override\n\tpublic void onError(Throwable throwable) {\n\n\t}\n}).execute();\n```\nThis can also be used to stream the returned body to a file instead of buffer all bytes in memory.\n\n\n## Server Side Events Api\nA server side event connection can be made by callign the createSSE method on the httpClient.\n```java\nSseClient sseClient = httpClient.createSSE(\"http://someUrl\").build().execute(new SseClientCallback() {\n\t\t@Override\n\t\tpublic void onConnect() {\n\n\t\t}\n\n\t\t@Override\n\t\tpublic void onDisconnect() {\n\n\t\t}\n\n\t\t@Override\n\t\tpublic void onError(Throwable throwable) {\n\n\t\t}\n\n\t\t@Override\n\t\tpublic void onEvent(String lastSentId, String event, String data) {\n\n\t\t}\n\t});\n\t\t\nsseClient.awaitClose();\n\n```\nThe SseClient also supports reconnecting after a connection has been lost\n```java\nsseClient.connect();\n```\nIt is also possible to subscribe specific events\n```java\nsseClient.onEvent(\"stocks\", new EventCallback() {\n\t@Override\n\tpublic void onEvent(String lastSentId, String event, String data) {\n\n\t}\n});\n\nsseClient.onConnect(new SseClient.ConnectCallback() {\n\t@Override\n\tpublic void onConnect() {\n\n\t}\n});\n\n\nsseClient.onDisconnect(new SseClient.DisconnectCallback() {\n\t@Override\n\tpublic void onDisconnect() {\n\n\t}\n});\n```\n\n## Web-sockets\nA websocket connection can be made by calling the createWebSocket on the httpClient.\n```java\nCompletableFuture\u003cWebSocketClient\u003e future = httpClient.createWebSocket(\"ws://some.server\").build().execute(new WebSocketListener() {\n\t@Override\n\tpublic void onConnect(WebSocketConnection connection) {\n\n\t}\n\n\t@Override\n\tpublic void onError(Throwable throwable) {\n\n\t}\n\n\t@Override\n\tpublic void onDisconnect() {\n\n\t}\n\n\t@Override\n\tpublic void onCloseFrame(int code, String reason) {\n\n\t}\n\n\t@Override\n\tpublic void onBinaryFrame(byte[] payload, boolean finalFragment, int rsv) {\n\n\t}\n\n\t@Override\n\tpublic void onTextFrame(String payload, boolean finalFragment, int rsv) {\n\n\t}\n});\n```\nIf no extra executor has been supplied into the websocket builder all callbacks will be executed on the NIO thread!\n\n\n## Thread model\n\nThe methods in HttpCallback are only invoked from the threads in HttpCallbackExecutor.\nThis means that you can have long running jobs without blocking IO operations for other requests. The executor will of course\nneed to be resized accordingly to prevent excessive queues.  \n\nThe methods in NioCallback are always invoked from the internal nio threads. They should therefore not be blocking nor long running. \nThe same goes for implementations of the ResponseBodyConsumer and MetricCallback interfaces.\n\n\n## Limitations\nDoes not support complex authentication (basic should work using the headers). Does not support proxys. Does not support http2.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fking%2Fking-http-client","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fking%2Fking-http-client","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fking%2Fking-http-client/lists"}